[Examination Reflection] 1002csp-s Simulation Test 57: mediocre

One day two, to feel complete.

Non-stick charts, too spectacular.

#1:190

#2:180

#4:160

#35:150

#37:140

#39:120

#kx: 20 uh. . .

The last one is the end of the exam.

CE cover is 40 minutes. In fact, not far away from # 2. . .

Debug statement did not clean, delete, open O2 compile a compilation error, you did not see, thought it was a piece of warning about the scanf.

However, not.

Must be carefully examined to compile information! ! ! The code must be compiled before delivery! ! !

In fact, there are almost pan T1, wrong question.

Seven minutes before the end of the exam re-read it again to find something wrong, + 100pts.

Look question! ! !

need to check! ! !

 

T1:

Not speak. Write super trouble.

 1 #include<cstdio>
 2 main(){
 3     int t;scanf("%d",&t);
 4     while(t--){
 5         int a,b,c,x,y,z;scanf("%d%d%d%d%d%d",&a,&b,&c,&x,&y,&z);
 6         int det=(x>a)+(y>b)+(z>c);
 7         if(det==0){puts("YES");continue;}
 8         if(det==3){puts("NO");continue;}
 9         if(det==2){
10             if(a>=x)puts(a-x>>1>=y-b+z-c?"YES":"NO");
11             if(b>=y)puts(b-y>>1>=x-a+z-c?"YES":"NO");
12             if(c>=z)puts(c-z>>1>=x-a+y-b?"YES":"NO");
1(it ==if14        }
13          ){
15             if(x>a)puts(x-a<=(b-y>>1)+(c-z>>1)?"YES":"NO");
16             if(y>b)puts(y-b<=(a-x>>1)+(c-z>>1)?"YES":"NO");
17             if(z>c)puts(z-c<=(a-x>>1)+(b-y>>1)?"YES":"NO");
18         }
19     }
20 }
View Code

 

T2:

Obviously the range of data like pressure n, but nothing like the pressure represent?

Because to make DAG, so there must be topological order, which points to keep the topology has been on the line.

But some topological order DAG is not unique. To swap inclusion and exclusion. (Inclusion and exclusion factor I will yy Proof)

Subset enumeration complement, efficient method to enumerate the subset has not, Internet decadent one.

for (int st = S; st; (- st) & = S); st this will traverse all of the subset S.

This problem is also serious card often, not by direct enumeration n this point to determine whether there is a binary, but to directly remove a lowbit.

 1 #include<cstdio>
 2 #define mod 1000000007
 3 int fir[18],l[299],to[299],cnt,n,m,cr[18],sz[1666666],pre[18],re[1666666];
 4 long long pw[111],dp[1666666];
 5 void link(int a,int b){l[++cnt]=fir[a];fir[a]=cnt;to[cnt]=b;}
 6 main(){//freopen("obelisk8.in","r",stdin);
 7     dp[0]=pw[0]=1;
 8     scanf("%d%d",&n,&m);
 9     for(int i=1,x,y;i<=m;++i)scanf("%d%d",&x,&y),link(x,y);
10     for(int st=1;st<1<<n;++st)sz[st]=sz[st^st&-st]+1;
11     for(int i=1;i<=n;++i)re[1<<i-1]=i;
12     for(int i=1;i<=100;++i)pw[i]=(pw[i-1]<<1)%mod;
13     for(int i=1;i<=n;++i)for(int j=fir[i];j;j=l[j])pre[i]|=1<<to[j]-1;
14     for(int st=0;st<1<<n;++st)
15         for(int U=(~st)&(1<<n)-1,S=U;S;(--S)&=U){
16             int cnt=0;
17             for(int i=st;i;i^=i&-i)cnt+=sz[S&pre[re[i&-i]]];
18             (dp[st|S]+=dp[st]*pw[cnt]*(sz[S]&1?1:-1)%mod+mod)%=mod;
19         }
20     printf("%lld\n",dp[(1<<n)-1]);
21 }
View Code

The accumulation of ideas:

  • DAG-dp: Sequence Topological compressed state
  • Magic inclusion-exclusion

 

T3:

40% of the violence written on the blackboard, in fact, not if M is 60, with a code.

 1 #include<cstdio>
 2 #include<iostream>
 3 using namespace std;
 4 int n,pr[30000005],md[100000005],prcnt;
 5 bool np[100000005];long long Ans=1;short ans[100000001],mdcnt[100000001];
 6 int main(){
 7     scanf("%d",&n);
 8     for(int i=2;i<=n;++i){
 9         if(!np[i])ans[i]=3,pr[++prcnt]=i,mdcnt[i]=1,md[i]=i;
10         for(int j=1;j<=prcnt&&i*pr[j]<=n;++j){
11             int T=i*pr[j];
12             md[T]=pr[j];np[T]=1;
13             mdcnt[T]=md[i]==pr[j]?mdcnt[i]+1:1;
14             ans[T]=ans[i]/(mdcnt[T]*2-1)*(mdcnt[T]*2+1);
15             if(i%pr[j]==0)break;
16         }
17     }
18     for(int i=2;i<=n;++i)Ans+=ans[i];
19     printf("%lld\n",(1ll*n*n-Ans)%1000000007);
20 }
View Code

Another 40 to 60 play is cbx and below said.

Many of them are first chicken house with inversion of A, I was too dishes I will not.

I go with cbx.

Crazy like a block number theory.

Problem is how to find the solution to a problem in the development of the function f, f values ​​obtained after the outer layers can block on n / d do.

F array observation, what difference it get g, g [k] What is the meaning?

It is [gcd (a, b) == 1] × a × b == k a, b, logarithmic.

Consider meaning, since a certain product, after decomposition of the quality factor then the factor k is assigned to the ab like.

If there is more than one kind of factor, then it must only give ab in an otherwise gcd is not 1.

In fact, then the value G [k] is 2 quality factor k species number (not a number). You can line screen

Then do it again prefix and you can get the f.

How find S function? On a more direct block number.

For large values ​​of f then you can find a recursive.

Not so difficult to imagine, though it will not permit.

 1 #include<cstdio>
 2 #define int long long
 3 #define mod 1000000007
 4 int pr[8000005],md[10000005],prcnt,f[10000005];
 5 bool np[10000005];int n,Ans;
 6 int S(int k){
 7     int ans=0;
 8     for(int i=1,lst;i<=k;i=lst+1)lst=k/(k/i),(ans+=(lst-i+1)%mod*(k/i))%=mod;
 9     return ans;
10 }
11 int F(int k){
12     if(k<=10000000)return f[k];int ans=0;
13     for(int j=2;j*j<=k;++j)(ans+=F(k/j/j))%=mod;
14     return (S(k)-ans+mod)%mod;
15 }
16 main(){
17     scanf("%lld",&n);f[1]=1;
18     for(int i=2;i<=10000000;++i){
19         if(!np[i])f[i]=2,pr[++prcnt]=i,md[i]=i;
20         for(int j=1;j<=prcnt&&i*pr[j]<=10000000;++j){
21             int T=i*pr[j];
22             md[T]=pr[j];np[T]=1;
23             f[T]=(f[i]<<(md[i]!=pr[j]))%mod;
24             if(i%pr[j]==0)break;
25         }
26     }
27     for(int i=2;i<=10000000;++i)(f[i]+=f[i-1])%=mod;
28     for(int i=1,lst;i<=n;i=lst+1)lst=n/(n/i),(Ans+=(lst-i+1)%mod*F(n/i)+mod)%=mod;
29     printf("%lld\n",(n%mod*(n%mod)%mod-Ans+mod)%mod);
30 }
View Code

The accumulation of ideas:

  • Block number theory: knowledge turned out to be the league point ah
  • Line a sieve: knowledge is certainly League

 

Guess you like

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