I did not mutter blog ah simulation tests of a number suddenly jumped and I do not know why.
This is still nothing to say.
$ T1 $ is probably a difficult league. . . simulation? Hard to say.
Too simple but easy to make people think complex. I do not know think of where to go thanks to a last admitted.
Then $ T2 $ card at constant so than no more than 4 points card.
However, to write $ $ T3 fried, the constant is too large to be $ 5 to $ card points.
Generally normal to play it.
$ T2 $ thinking very wonderful, can not think.
But after $ T3 $ test did not understand this too, strange polynomial expansion, we had to take the time to get it back. .
T1:Alchemy
Effect: Given $ hanoi $ situation. It is the first steps to determine the optimal solution. $ N \ le 50 $
simulation? One by one to determine where each dish just fine.
1 #include<bits/stdc++.h> 2 using namespace std; 3 int p[55],t,n,ok; 4 long long sch(int x,int f,int t,int e){ 5 if(!x)return 0; 6 if(p[x]==e)return ok=0; 7 if(p[x]==f)return 1ll<<x-1|sch(x-1,f,e,t); 8 if(p[x]==t)return sch(x-1,e,t,f); 9 } 10 int main(){ 11 cin>>t;while(t--){ 12 ok=1;n=0; 13 for(int i=0,k,x;i<3;++i){ 14 scanf("%d",&k);n+=k; 15 while(k--)scanf("%d",&x),p[x]=i; 16 } 17 long long r=sch(n,0,2,1); 18 if(ok)cout<<r<<endl;else puts("No"); 19 } 20 }
T2:Algebra
Effect: n-$ $ seeking greater than or equal to meet every smallest at $ a, b $ and decimal equivalent. $ N \ le 10 ^ {16}, a, b, \ le 36 $
Provided a $ next (n, k, s) $ represents than or equal to n-$ $ $ k $ of the smallest and is the hexadecimal number $ s $. This can be bit by bit greedy.
We then use a similar method to the shortest of all $ (n, s) pair $ thrown into the pile. Takes out an extension.
If $ next (n, a, s) = next (n, b, s) = n $ then the answer may be output. Otherwise $ (max (next (n, a, s), next (n, b, s)), s) $ throw into.
The final answer is $ O (n) $-level explanation about it can be an effective maximum $ s $ it $ 400 $
Since this operation so carry $ next (a) $ and $ next (b) $ interleaving is random distribution law. According to the birthday paradox, the number of calls to only $ next $ $ O (\ sqrt {n}) $ times.
And it can be relatively small constant.
1 #include<bits/stdc++.h> 2 using namespace std; 3 #define ll long long 4 struct x{ 5 ll n;int s; 6 friend bool operator<(x a,x b){return a.n>b.n;} 7 };priority_queue<x>q; 8 int mxt[38],bit[65],b[65];ll pw[38][65]; 9 bool chk(int al,int k,int s){ 10 for(int i=al;~i;--i)b[i]=0; 11 int p=al; 12 while(s>=k-1){ 13 if(bit[p]<k-1)return 1; 14 b[p]=k-1,p--,s-=k-1; 15 } 16 b[p]=s;if(s>bit[p])return 1;else if(s<bit[p])return 0; 17 for(int i=p;~i;--i)if(b[i]>bit[i])return 1;else if(b[i]<bit[i])return 0; 18 return 1; 19 } 20 ll sch(int al,int k,int s,int lim=1){ 21 if(al==-1)return 0; 22 for(int x=max(lim?bit[al]:0,s-(k-1)*al);x<k&&x<=s;++x)if(!lim||x>bit[al]||chk(al-1,k,s-x)) 23 return sch(al-1,k,s-x,lim&x==bit[al])+pw[k][al]*x; 24 return 1ll<<62; 25 } 26 ll nxt(ll n,int k,int s){ 27 for(int i=0;i<65;++i)bit[i]=0; 28 int cnt=0; 29 while(n)bit[cnt]=n%k,n/=k,cnt++; 30 return sch(mxt[k]-1,k,s); 31 } 32 int main(){ 33 for(int i=2;i<37;++i){ 34 pw[i][0]=1; 35 while(pw[i][mxt[i]]<1ll<<55)++mxt[i],pw[i][mxt[i]]=pw[i][mxt[i]-1]*i; 36 ++mxt[i],pw[i][mxt[i]]=pw[i][mxt[i]-1]*i; 37 } 38 int t;cin>>t;while(t--){ 39 ll n;int a,b,s;cin>>n>>a>>b; 40 for(int s=0;s<400;++s)q.push((x){n,s}); 41 while(1){ 42 n=q.top().n;s=q.top().s;q.pop(); 43 ll A=nxt(n,a,s),B=nxt(n,b,s); 44 if(A==B&&A==n){cout<<n<<endl;goto E;} 45 q.push((x){max(A,B),s}); 46 }E:;while(!q.empty())q.pop(); 47 } 48 }
T3:Anarchy
Effect: high-dimensional polynomial convolution. $ N = \ prod times_i \ le 10 ^ 5 $
Probably means that we need to construct a $ DFT $ so as to satisfy:
Set $ i, j, y $ two high dimensional vectors. Then $ ans_y = \ \ limits_ {i + j = y} x_i \ times y_j sum $
Wherein plus conditions, meaning lower mold, each of the dimensions are equal.
We found that this condition need only turn to do it again for each dimension circular convolution of $ DFT $ enough.
Clearly the establishment of minimum dimensions, higher dimensions just tell replaced with a sequence number, it is the same.
So you can make $ DFT $ a. Such complexity is $ O (n \ sum times_i) $ a.
Then just do not understand. A pigeon. Free to come back and see.