2018 ACM 网络选拔赛 沈阳赛区

Posted cmyg

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2018 ACM 网络选拔赛 沈阳赛区相关的知识,希望对你有一定的参考价值。

 

B. Call of Accepted

  1 #include <cstdio>
  2 #include <cstdlib>
  3 #include <cmath>
  4 #include <cstring>
  5 #include <time.h>
  6 #include <string>
  7 #include <set>
  8 #include <map>
  9 #include <list>
 10 #include <stack>
 11 #include <queue>
 12 #include <vector>
 13 #include <bitset>
 14 #include <ext/rope>
 15 #include <algorithm>
 16 #include <iostream>
 17 using namespace std;
 18 #define ll long long
 19 #define minv 1e-6
 20 #define inf 1e9
 21 #define pi 3.1415926536
 22 #define nl 2.7182818284
 23 const ll mod=1e9+7;//998244353
 24 const int maxn=1e2+10;
 25 
 26 /**
 27 + - 3
 28 * / 2
 29 d   1
 30 ( ) 0
 31 **/
 32 
 33 int xl[maxn],xr[maxn],y[maxn];
 34 char s[maxn],z[maxn];
 35 
 36 int main()
 37 {
 38     int len,i,g1,g2,a,b,c,d,sym;
 39     while (~scanf("%s",s))
 40     {
 41         len=strlen(s);
 42         g1=0;
 43         g2=0;
 44         y[0]=inf;
 45         for (i=0;i<len;i++)
 46             if (s[i]>=0 && s[i]<=9)
 47             {
 48                 g1++;
 49                 xl[g1]=0;
 50                 while (s[i]>=0 && s[i]<=9)
 51                 {
 52                     xl[g1]=xl[g1]*10+s[i]-48;
 53                     i++;
 54                 }
 55                 i--;
 56                 xr[g1]=xl[g1];
 57             }
 58             else
 59             {
 60                 switch(s[i])
 61                 {
 62                     case (:
 63                         sym=0;
 64                         break;
 65                     case ):
 66                         sym=0;
 67                         break;
 68                     case d:
 69                         sym=1;
 70                         break;
 71                     case *:
 72                         sym=2;
 73                         break;
 74                     case /:
 75                         sym=2;
 76                         break;
 77                     case +:
 78                         sym=3;
 79                         break;
 80                     case -:
 81                         sym=3;
 82                         break;
 83                 }
 84                 while (y[g2]<=sym || s[i]==))
 85                 {
 86                     switch(z[g2])
 87                     {
 88                         case d:
 89                             ///ldr l>=0,r>=1,else illegal
 90                             ///正数,负数
 91                             xl[g1-1]=max(0,xl[g1-1]);
 92                             xl[g1]=max(1,xl[g1]);
 93                             xr[g1-1]*=xr[g1];
 94                             break;
 95                         case +:
 96                             xl[g1-1]+=xl[g1];
 97                             xr[g1-1]+=xr[g1];
 98                             break;
 99                         case -:
100                             xl[g1-1]-=xr[g1];
101                             xr[g1-1]-=xl[g1];
102                             break;
103                         case *:
104                             a=xl[g1-1]*xl[g1];
105                             b=xl[g1-1]*xr[g1];
106                             c=xr[g1-1]*xl[g1];
107                             d=xr[g1-1]*xr[g1];
108                             xl[g1-1]=min(min(a,b),min(c,d));
109                             xr[g1-1]=max(max(a,b),max(c,d));
110                             break;
111                         case /:
112                             a=xl[g1-1]/xl[g1];
113                             b=xl[g1-1]/xr[g1];
114                             c=xr[g1-1]/xl[g1];
115                             d=xr[g1-1]/xr[g1];
116                             xl[g1-1]=min(min(a,b),min(c,d));
117                             xr[g1-1]=max(max(a,b),max(c,d));
118                             break;
119                         case (:
120                             break;
121                     }
122                     if (z[g2]==()
123                         break;
124                     g2--;
125                     g1--;
126                 }
127                 if (s[i]==))
128                     g2--;
129                 else
130                 {
131                     y[++g2]=sym;
132                     z[g2]=s[i];
133                 }
134             }
135 
136         while (g2!=0)
137         {
138             switch(z[g2])
139             {
140                 case d:
141                     xr[g1-1]*=xr[g1];
142                     break;
143                 case +:
144                     xl[g1-1]+=xl[g1];
145                     xr[g1-1]+=xr[g1];
146                     break;
147                 case -:
148                     xl[g1-1]-=xr[g1];
149                     xr[g1-1]-=xl[g1];
150                     break;
151                 case *:
152                     a=xl[g1-1]*xl[g1];
153                     b=xl[g1-1]*xr[g1];
154                     c=xr[g1-1]*xl[g1];
155                     d=xr[g1-1]*xr[g1];
156                     xl[g1-1]=min(min(a,b),min(c,d));
157                     xr[g1-1]=max(max(a,b),max(c,d));
158                     break;
159                 case /:
160                     a=xl[g1-1]/xl[g1];
161                     b=xl[g1-1]/xr[g1];
162                     c=xr[g1-1]/xl[g1];
163                     d=xr[g1-1]/xr[g1];
164                     xl[g1-1]=min(min(a,b),min(c,d));
165                     xr[g1-1]=max(max(a,b),max(c,d));
166                     break;
167                 case (:
168                     break;
169             }
170             g2--;
171             g1--;
172         }
173 
174         printf("%d %d
",xl[1],xr[1]);
175     }
176 
177     return 0;
178 }
179 /*
180 3*(2d3)
181 1+1d2d3d4d5+2
182 
183 (2d3)*(1+3*3d4)d5
184 
185 (2+(3*4+5d1d3)d2)d3
186 
187 
188 
189 (10-30)*3d4
190 
191 (10-3d4)*2d3
192 
193 (10-3d4)*(10-3d4)
194 
195 (10-5d5)*(10-5d5)
196 
197 3d(10-3d4)
198 3d(10-3d4)d(10-3d4)
199 */

 

 

 

I. Lattice‘s basics in digital electronics

  1 #include <cstdio>
  2 #include <cstdlib>
  3 #include <cmath>
  4 #include <cstring>
  5 #include <time.h>
  6 #include <string>
  7 #include <set>
  8 #include <map>
  9 #include <list>
 10 #include <stack>
 11 #include <queue>
 12 #include <vector>
 13 #include <bitset>
 14 #include <ext/rope>
 15 #include <algorithm>
 16 #include <iostream>
 17 using namespace std;
 18 #define ll long long
 19 #define minv 1e-6
 20 #define inf 1e9
 21 #define pi 3.1415926536
 22 #define nl 2.7182818284
 23 const ll mod=1e9+7;//998244353
 24 const int maxn=1e5+10;
 25 
 26 int tr[1000000];
 27 char s1[200010*10],s2[200010*10],s3[200010*10],s4[200010*10];
 28 char s[200010*10];
 29 
 30 int main()
 31 {
 32     int t,m,n,a,i,j,k,len,now,g,value;
 33     scanf("%d",&t);
 34     while (t--)
 35     {
 36         memset(tr,0,sizeof(tr));
 37         scanf("%d%d",&m,&n);
 38         for (i=1;i<=n;i++)
 39         {
 40             scanf("%d%s",&a,s);
 41             len=strlen(s);
 42             k=1;
 43             for (j=0;j<len;j++)
 44                 k=(k<<1)+s[j]-48;
 45             tr[k]=a;
 46         }
 47 
 48         scanf("%s",s1);
 49         len=strlen(s1);
 50         j=0;
 51         for (i=0;i<len;i++)
 52         {
 53             if (s1[i]>=0 && s1[i]<=9)
 54                 value=s1[i]-48;
 55             else if (s1[i]>=A && s1[i]<=F)
 56                 value=s1[i]-55;
 57             else
 58                 value=s1[i]-87;
 59 
 60             s2[j++]=value/8+48;
 61             value%=8;
 62             s2[j++]=value/4+48;
 63             value%=4;
 64             s2[j++]=value/2+48;
 65             value%=2;
 66             s2[j++]=value+48;
 67         }
 68         s2[j]=;
 69         len=j;
 70 
 71         now=0;
 72         for (i=0;i<len/9;i++)
 73         {
 74             g=0;
 75             j=i*9;
 76             for (k=j;k<j+8;k++)
 77                 g+=s2[k]-48;
 78             if ((g+1)%2==s2[k]-48)
 79             {
 80                 for (k=j;k<j+8;k++)
 81                     s3[now++]=s2[k];
 82             }
 83         }
 84         s3[now]=;
 85 
 86         j=1;
 87         len=0;
 88         for (i=0;i<now;i++)
 89         {
 90             j=j*2+s3[i]-48;
 91             if (j>10000)
 92                 continue;
 93             if (tr[j])
 94             {
 95                 s4[len++]=tr[j];
 96                 if (len==m)
 97                     break;
 98                 j=1;
 99             }
100         }
101         s4[len]=;
102         printf("%s
",s4);
103     }
104     return 0;
105 }
106 /*
107 10
108 8 3
109 49 0001
110 50 01001
111 51 011
112 14DB24722698
113 
114 
115 2
116 15 9
117 32 0100
118 33 11
119 100 1011
120 101 0110
121 104 1010
122 108 00
123 111 100
124 114 0111
125 119 0101
126 908
127 
128 100
129 100 2
130 65 010
131 66 1011
132 AAAAAA
133 */

 

K. Supreme Number

  1 #include <cstdio>
  2 #include <cstdlib>
  3 #include <cmath>
  4 #include <cstring>
  5 #include <time.h>
  6 #include <string>
  7 #include <set>
  8 #include <map>
  9 #include <list>
 10 #include <stack>
 11 #include <queue>
 12 #include <vector>
 13 #include <bitset>
 14 #include <ext/rope>
 15 #include <algorithm>
 16 #include <iostream>
 17 using namespace std;
 18 #define ll long long
 19 #define minv 1e-6
 20 #define inf 1e9
 21 #define pi 3.1415926536
 22 #define nl 2.7182818284
 23 const ll mod=1e9+7;//998244353
 24 const int maxn=1e5+10;
 25 
 26 typedef pair<int,int> P;
 27 
 28 char str[maxn];
 29 int g=0,b,a[maxn];
 30 int c[5]={1,2,3,5,7};
 31 int shi[10];
 32 
 33 bool prime(int t)
 34 {
 35     int i;
 36     for (i=2;i<=sqrt(t);i++)
 37         if (t%i==0)
 38             return 0;
 39     return 1;
 40 }
 41 
 42 void dfs(int s,int w,vector<P>v)
 43 {
 44     vector<P>::iterator j;
 45     vector<P>vv;
 46     int t,i;
 47 
 48     for (i=0;i<5;i++)
 49     {
 50 
 51 //        if (shi[w]*c[i]+s==711)
 52 //            printf("z");
 53 
 54         for (j=v.begin();j!=v.end();j++)
 55         {
 56             if (!prime(j->first+shi[j->second]*c[i]))
 57                 break;
 58         }
 59 
 60         if (j==v.end())
 61         {
 62             t=shi[w]*c[i]+s;
 63             vv.clear();
 64             for (j=v.begin();j!=v.end();j++)
 65             {
 66                 vv.push_back(make_pair(j->first,j->second));
 67                 vv.push_back(make_pair(j->first+shi[j->second]*c[i],j->second+1));
 68             }
 69             vv.push_back(make_pair(c[i],1));
 70 
 71 //            printf("%d:
",t);
 72 //            for (j=vv.begin();j!=vv.end();j++)
 73 //                printf("%d
",j->first);
 74 
 75             g++;
 76             a[g]=t;
 77             dfs(t,w+1,vv);
 78         }
 79     }
 80 }
 81 
 82 int main()
 83 {
 84     vector<P>v;
 85     int t,T,i;
 86 //    cout<<pow(10,0)<<endl;
 87 //    cout<<pow(10,1)<<endl;
 88 //    cout<<pow(10,2)<<endl;
 89 //
 90 //    printf("
");
 91 //
 92 //    printf("%f
",pow(10,0));
 93 //    printf("%f
",pow(10,1));
 94 //    printf("%f
",pow(10,2));
 95 //
 96 //    printf("
");
 97 //
 98 //    printf("%d
",pow(10,0));
 99 //    printf("%d
",pow(10,1));
100 //    printf("%d
",pow(10,2));
101 //
102 //    printf("
");
103 //
104 //    printf("%d
",(int)pow(10,0));
105 //    printf("%d
",(int)pow(10,1));
106 //    printf("%d
",(int)pow(10,2));
107 //
108 //    printf("
");
109 //
110 //    printf("
");
111 //
112 //    printf("%f
",log(2)/log(2));
113 //    printf("%f
",log(4)/log(2));
114 //    printf("%f
",log(8)/log(2));
115 //    printf("%f
",log(16)/log(2));
116 //
117 //    printf("%d
",(int)(log(2)/log(2)));
118 //    printf("%d
",(int)(log(4)/log(2)));
119 //    printf("%d
",(int)(log(8)/log(2)));
120 //    printf("%d
",(int)(log(16)/log(2)));
121 //
122 //    printf("
");
123 //
124 //    printf("%d
",(int)log(2)/log(2));
125 //    printf("%d
",(int)log(4)/log(2));
126 //    printf("%d
",(int)log(8)/log(2));
127 //    printf("%d
",(int)log(16)/log(2));
128 //    return 0;
129 
130     shi[0]=1;
131     for (i=1;i<=9;i++)
132         shi[i]=shi[i-1]*10;
133 
134     v.push_back(make_pair(0,0));
135     dfs(0,0,v);
136     sort(a+1,a+g+1);
137 
138 //    for (i=1;i<=g;i++)
139 //        printf("%d ",a[i]);
140 
141     scanf("%d",&t);
142     for (T=1;T<=t;T++)
143     {
144         scanf("%str",str);
145         if (strlen(str)>9)
146         {
147             printf("Case #%d: %d
",T,a[g]);
148             continue;
149         }
150         b=atoi(str);
151         for (i=g;i>=1;i--)
152             if (b>=a[i])
153                 break;
154         printf("Case #%d: %d
",T,a[i]);
155     }
156     return 0;
157 }

 

以上是关于2018 ACM 网络选拔赛 沈阳赛区的主要内容,如果未能解决你的问题,请参考以下文章

ACM-ICPC 2018 沈阳赛区网络预赛

ACM-ICPC 2018 沈阳赛区网络预赛

ACM-ICPC 2018 沈阳赛区网络预赛

ACM-ICPC 2018 沈阳赛区网络预赛 KSupreme Number

2018 ACM 网络选拔赛 南京赛区

ACM-ICPC 2018 沈阳赛区网络预赛 DMade In Heaven