[Exam reflection] mathematical topics Test 1: missing

Caught in a row side by side in large no idea. . .

On my T1 what happened? Variable declarations wrong line, exLucas understanding is not profound.

This is something the league ah. . . Board problem, as always explode.

However, violence T2 of 50 points is the board, dip a little bit faster progress a little impression of light, but I do not know the correct form, then tried for an hour of argument in the examination room. . .

However, T3 has been persistent thought in mind pruning faster than search-like pressure, but the problem apparently did not stay in this file score. . .

In fact, T3 have guessed a defined status, but the transfer is really unthinkable. . .

The four and a half hours had inexplicably fast. . . Instant no time

T1 had wanted to write to shoot, if you really write that variable even if exLucas not tune out can be found, whatever the outcome is 70 points. . .

Still a little too relaxed. . . Waste too much time T3, T1 beat too slowly (or simply not thought to get up?), And T2 and because the conclusions did not take too long back. . .

Or to correct the attitude of some, usually done or should remember some questions. . .

I feel that they have to write on the topic of 60+ beat. . . He died in violence Shanghao than just a number

And do not always think the topic and people do not give you points that you can set up water in the past, time enough, then you can try is not enough time or do not waste too much time on this kind of thing.

How can the topic of human cancer is, data not full of it?

 

T1: solving equations

Title effect: n is a positive integer and m, n1 for the variable has upper bound limitation for the upper bound n2 variables have limitations. Find a few programs.

The answer to $ 10007 $, $ 262203414 = 2 \ times 3 \ times 11 \ times 397 \ times 10007 $ or $ 437367875 = 5 ^ 3 \ times 7 ^ 3 \ times 101 ^ 2 $ modulo.

$ N, m \ 10 ^ $ 9, $ n1, n2 \ $ 8

8 to see the range of data that you know is like pressing enumerate the inclusion-exclusion, then the rest a exLucas + CRT.

exLucas is proposed to carry out a certain number of quality operations. However, the remaining portion of the algorithm coefficients is a recursive process, constantly consider p is a multiple of two parts and multiples are considered non-p.

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int n,n1,n2,P,T,m,p[6],pc,k[6],pk[6],lim[9],ans[6],fac[6][11111],Tm[6][11111],K=1,Tms=0;
 4 int pow(int b,int t,int mod,int a=1){for(;t;t>>=1,b=1ll*b*b%mod)if(t&1)a=1ll*a*b%mod;return a;}
 5 void exgcd(int a,int b,int&x,int&y){
 6     if(!b){x=1;y=0;return;}
 7     exgcd(b,a%b,x,y);int r=x;x=y;y=r-a/b*x;
 8 }
 9 int inv(int x,int P){int a,b;exgcd(x,P,a,b);return (a%P+P)%P;}
10 int CRT(){
11     int tp=pk[1],la=ans[1];
12     for(int i=2;i<=pc;++i){
13         int k1,k2;exgcd(tp,pk[i],k1,k2);
14         k1*=ans[i]-la;la=(1ll*tp*k1%(tp*pk[i])+la+tp*pk[i])%(tp*pk[i]);tp*=pk[i];
15     }return la;
16 }
17 void cal(int x,int i,int o){
18     if(x<p[i]){K=K*(o==1?fac[i][x]:inv(fac[i][x],pk[i]))%pk[i];return;}
19     cal(x/p[i],i,o);Tms+=x/p[i]*o;
20     if(o==1)K=K*fac[i][x%pk[i]]%pk[i]*pow(fac[i][pk[i]],x/pk[i],pk[i])%pk[i];
21     else K=K*inv(fac[i][x%pk[i]]*pow(fac[i][pk[i]],x/pk[i],pk[i]),pk[i])%pk[i];
22 }
23 main(){//freopen("1.in","r",stdin);
24     cin>>T>>P;//if(P==437367875)return 0;
25     for(int i=2;i*i<=P;++i)if(P%i==0){
26         p[++pc]=i;pk[pc]=1;
27         while(P%i==0)k[pc]++,pk[pc]*=i,P/=i;
28     }if(P^1)p[++pc]=P,k[pc]=1,pk[pc]=P;
29     for(int i=1;i<=pc;++i)fac[i][0]=1;
30     for(int i=1;i<=pc;++i)for(int j=1;j<=pk[i];++j)fac[i][j]=fac[i][j-1]*(j%p[i]?j:1)%pk[i];
31     while(T--){
32         cin>>n>>n1>>n2>>m;
33         for(int i=1;i<=n1;++i)cin>>lim[i];
34         for(int i=1,x;i<=n2;++i)cin>>x,m-=x-1;
35         for(int I=1;I<=pc;++I){
36             ans[I]=0;
37             for(int s=0;s<1<<n1;++s){int rt=1,M=m-1;
38                 for(int j=0;j<n1;++j)if(s&1<<j)rt*=-1,M-=lim[j+1];
39                 if(M<n-1)continue;Tms=0,K=1;cal(M,I,1);cal(n-1,I,-1);cal(M-n+1,I,-1);
40                 ans[I]=(ans[I]+rt*K*1ll*pow(p[I],Tms,pk[I])%pk[I]+pk[I])%pk[I];
41             }
42         }cout<<CRT()<<endl;
43     }
44 }
View Code

 

 

T2: Universe sequence

Title effect: a given length $ 2 ^ n $ is the number of columns $ A $, isobutyl or convolutional $ I $ times to get $ A_i $, seeking $ \ sum \ limits_ {i = 0} ^ {p} A_ {2 ^ i } [j] $.

$ P \ 10 ^ 9, n \ 18, mod = $ 10007

Since convolution is associative, it is easy to think of doubling.

Then the violence will have 50 points of the FWT convolution. However, I will not, so crazy test parameters in the examination room. Maybe this thing is not difficult to prove, but it is really difficult yy.

In fact $ A_0 = A_0-A_1, A_1 = A_0 + A_1 $ is the DFT process. IDFT inversion on the line.

This problem is very small and easy to think of looking modulus cycling festival, in fact the entire length of the cycle section the number of columns is $ 5002 $ However this is useless.

Complexity $ O (mod ^ 2) $ approach is to find the number of cycles for each section, as point values are additive so directly increase. After the beginning DFT section obtained directly by cyclic prefix and the point value again IDFT.

However, positive solutions are doubled. First get the point value of the original series DFT, then we just need to get the point value of the prefix and number sequence IDFT back on the line. Because the point value may be a prefix added so that the number sequence is the corresponding point value is actually the number of columns and a point value corresponding to the item.

For the position of the origin value of $ X $, we require that the $ \ sum \ limits_ {i = 0} ^ {p} x ^ {2 ^ i} $, set $ f [x] [i] = \ sum \ limits_ {j = 0} ^ {2 ^ i-1} x ^ {2 ^ j} $

Multiplying obtained $ f $ array: $ f [x] [i] = f [x] [i-1] + f [x ^ {2 ^ {2 ^ {i-1}}}] [i-1] $ . Then just as quickly as a power base while updating while updating answer it.

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define mod 10007
 4 int n,a[262145],b[262145],f[mod][30],p,j,ans;
 5 int pow(int b,int t,int m=mod,int a=1){for(;t;t>>=1,b=b*b%m)if(t&1)a=a*b%m;return a;}
 6 int main(){
 7     cin>>n>>p>>j;n=1<<n;p++;
 8     for(int i=0;i<n;++i)cin>>a[i];
 9     for(int i=1;i<n;i<<=1)for(int j=0;j<n;j+=i<<1)for(int k=0,x,y;k<i;++k)
10         x=a[j+k],y=a[j+k+i],a[j+k]=(x-y+10007)%10007,a[j+k+i]=(x+y)%10007;
11     for(int i=0;i<mod;++i)f[i][0]=i;
12     for(int t=1;t<30;++t)for(int i=0;i<mod;++i)f[i][t]=(f[i][t-1]+f[pow(i,pow(2,1<<t-1,mod-1))][t-1])%mod;
13     for(int i=0;i<n;++i)for(int t=29;~t;--t)if(p&1<<t)b[i]=(b[i]+f[a[i]][t])%mod,a[i]=pow(a[i],pow(2,1<<t,mod-1));
14     for(int i=1;i<n;i<<=1)for(int j=0;j<n;j+=i<<1)for(int k=0,x,y;k<i;++k)
15         x=b[j+k],y=b[j+k+i],b[j+k]=(x+y)%10007*5004%10007,b[j+k+i]=(y-x+10007)*5004%10007;
16     cout<<b[j]<<endl;
17 }
View Code

 

 

 T3:exp

The desired interval dp. It will not do, pigeon pigeon pigeon Gugu Gu.

Guess you like

Origin www.cnblogs.com/hzoi-DeepinC/p/12134666.html