Suggested name: TLEcoders
Pass the exam
Come up and see, four questions, three math questions, Gan
I finally saw the expected linearity after exploding the \ (998244353 \) field, so I took T1 seconds for 15min, and then T2 began to play the sample. After that, I found that it was also very water, just seconds. At this time, I felt like taking off, and T3 found that it would not...
Fortunately, the data was random, so I began to mess around, judged the special nature, and felt that the minimum guarantee was 60. When I opened T4, I saw that it was a number theory. First, I yy worked out the linear screening method for half an hour, and suddenly found that it was very similar to the problem I had done before, so I wanted to enumerate the square factors, and then a wave of tolerance and rejection, and passed the example!!! Drive, 80 to hand
Therefore, the expected score is 100 + 100 + [60-80] + 80 = [340-360], and the rest is basically checked
The distributor is stupid. T1#define int long long is stuck for 60, and T2 accuracy is stuck for 75
In short, the competition experience is very poor
T1. Set mean card routine
Direct expansion is equivalent to putting the average on the right to the left each time, and setting the average as \ (p \), the answer is
#include <bits/stdc++.h> using namespace std; const int mod=998244353; const int N=100050; int a[N],m,n,inv[200*N]; signed main() { freopen("mos.in","r",stdin); freopen("mos.out","w",stdout); cin>>n>>m;int sum=0; for(int i=1;i<=n;i++)scanf("%lld",&a[i]); for(int i=1;i<=n;i++)sum=(1ll*sum+a[i])%mod; inv[1]=1;for(int i=2;i<=n*m+10;i++)inv[i]=(1ll*mod-mod/i)*inv[mod%i]%mod; sum=1ll*sum*inv[n]%mod;int ans=0; for(int i=1;i<=n*m;i++)ans=(1ll*ans+1ll*sum*i%mod*inv[i+1]%mod)%mod; cout<<ans<<endl; return 0; }
T2. Polyalkylene glycol frying problem
From back to front, set \ (ans \) to 0 initially
For the current random number generator \ (i \), it is discussed by case
If there is no current priority in the following, i.e. \ (ANS < = l_i \), the current one should not be followed, \ (ans=(l_i+r_i)/2 \)
If the latter is completely better than the current, that is \ (ANS > = r_i \), regardless of the current, continue directly
Otherwise, the latter must be in the current range. The strategy is to select the next one if the selected number is smaller than the latter one. Otherwise, keep the current one, and the answer is
#include <bits/stdc++.h> using namespace std; #define int long long #define double long double inline int read() { int x=0;char ch=getchar(); while(ch<'0'||ch>'9')ch=getchar(); while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar(); return x; } const int N=1000050; const double exs=1e-15; inline bool pd(double x,double y) { if(x<y)swap(x,y); if(x-y<exs)return 1; return 0; } int l[N],r[N],n; signed main() { freopen("pag.in","r",stdin); freopen("pag.out","w",stdout); cin>>n;for(int i=1;i<=n;i++)l[i]=read(),r[i]=read(); double ans=0.0; for(int i=n;i>=1;i--) { if(ans<l[i]||pd(ans,l[i])){ans=(1.0*l[i]+r[i])/2.0;continue;} if(ans>r[i]||pd(ans,r[i]))continue; double p=(ans-l[i])/(1.0*r[i]-l[i]); ans=ans*p+(1.0-p)*((1.0*r[i]+ans)/2.0); } printf("%.5Lf",ans); return 0; }
T3. Technical Intelligence Agency
I don't know how the name came from
Build a large root Cartesian tree. Each node maintains the sum of the current interval prefix product, the sum of the suffix product and the interval product, and then dfs merges the statistical answers
#include <bits/stdc++.h> using namespace std; #define int long long const int N=1e7+10; namespace GenHelper{ unsigned z1, z2, z3, z4, b; unsigned rand_() { b=((z1<<6)^z1)>>13; z1=((z1&4294967294U)<<18)^b; b=((z2<<2)^z2)>>27; z2=((z2&4294967288U)<<2)^b; b=((z3<<13)^z3)>>21; z3=((z3&4294967280U)<<7)^b; b=((z4<<3)^z4)>>12; z4=((z4&4294967168U)<<13)^b; return (z1^z2^z3^z4); } } int a[N],ls[N],rs[N],root; void get(int n,unsigned s,int l,int r) { using namespace GenHelper; z1=s; z2=unsigned((~s)^0x233333333U); z3=unsigned(s^0x1234598766U); z4=(~s)+51; for(int i=1;i<=n;i++) { int x=rand_()&32767; int y=rand_()&32767; a[i]=l+(x*32768+y)%(r-l+1); } } int n,s,l,r,mod,ans;stack <int> st; int sum[N],p1[N],p2[N]; void dfs(int x) { if(ls[x])dfs(ls[x]); if(rs[x])dfs(rs[x]); ans=(ans+(p2[ls[x]]*p1[rs[x]]%mod*a[x]%mod+(p1[rs[x]]+p2[ls[x]])%mod*a[x]%mod+a[x])%mod*a[x]%mod)%mod; p1[x]=(p1[ls[x]]+(p1[rs[x]]+1)*((ls[x]?sum[ls[x]]:1ll)*a[x]%mod)%mod)%mod; p2[x]=(p2[rs[x]]+(p2[ls[x]]+1)*((rs[x]?sum[rs[x]]:1ll)*a[x]%mod)%mod)%mod; sum[x]=(ls[x]?sum[ls[x]]:1)*(rs[x]?sum[rs[x]]:1)%mod*a[x]%mod; } signed main() { freopen("tio.out","w",stdout); freopen("tio.in","r",stdin); cin>>n>>s>>l>>r>>mod; get(n,s,l,r); for(int i=1;i<=n;i++) { int p=0; while(st.size()&&a[st.top()]<a[i])p=st.top(),st.pop(); if(st.size())rs[st.top()]=i; if(p)ls[i]=p;st.push(i); } while(st.size()>1)st.pop();root=st.top(); dfs(root);cout<<ans<<endl; return 0; }
T4. KFC
Consider when there is no contribution, that is, when a number has a square factor
Then we want to eliminate the square factor. Because the upper bound is \ (\ sqrt n \), it is OK. Because it can calculate heavy, it needs to be excluded. Thinking about the practical significance of Mobius function, we will find that the exclusion coefficient is \ (\ mu \), let \ (g(x)=\sum_{i=1}^x i \), then the answer is
In fact, it can be divided into number theory blocks. There are only about three values of the root sign \ (n \), so it's done
#include <bits/stdc++.h> using namespace std; #define int unsigned long long const int N=10000050; int p[N],tot,mu[N],f[N];bool v[N]; inline int get(int x) { if(x&1)return ((x+1)>>1)*x; else return (x>>1)*(x+1); } signed main() { freopen("kfc.in","r",stdin); freopen("kfc.out","w",stdout); mu[1]=1; for(signed i=2;i<=1e7+10;i++) { if(!v[i]){p[++tot]=i;mu[i]=-1;} for(signed j=1;j<=tot&&p[j]*i<=1e7+10;j++) { v[i*p[j]]=1; if(i%p[j]==0){mu[p[j]*i]=0;break;} else mu[p[j]*i]=-mu[i]; } } for(int i=1;i<=1e7+10;i++)f[i]=f[i-1]+mu[i]*i*i; int t;cin>>t; for(int i=1;i<=t;i++) { int x;scanf("%llu",&x); int ans=0,lim=sqrt(x); for(int l=1,r;l<=lim;l=r+1) { r=min((int)sqrt(x/(x/(l*l))),lim); ans+=(f[r]-f[l-1])*get(x/(l*l)); } printf("%llu\n",ans); } return 0; }
Examination summary
Once again, the problem of small details is exposed. If you think you have written a positive solution, you'd better make limit data to see
The foundation is still not strong, the board can't write, and the problem has no ideas
Then you should play steadily and don't lose every point