This time it's embarrassing. A to D, then write a to D ...
A Checkerboard Problem
Brain teasers, it is not difficult to find that every time two people can only dye Baichi several lattice, so the number of odd or even a number of white lattice on the line.
#include <cstdio> #include <cstring> #include <cctype> #include <algorithm> #define REP (i,s,t) for (int. i=s;i<=t;i++) #define DWN (i,s,t) for (int i=s;i>=t;i--) using namespace Std;inline int Read () { int x=0,f =1;char C=getchar (); for (;! IsDigit (c); C=getchar ()) if (c== '-') f=-1; for (; IsDigit (c); C=getchar ()) x=x*10+c-' 0 '; return x*f;} typedef long LONG Ll;const int maxn=110;int n,m;void solve () {n=read (); M=read (); int Is=0;rep (I,1,N) Rep (j,1,m) Is+=read () ;p UTS ((is&1)? " Yadang ":" Xiawa ");} int main () {Dwn (T,read (), 1) solve (); return 0;}
B Approximate and
It is not difficult to find b=1*a,c=1*b, that is, c=1*1*a, here are number theory convolution.
Preprocessing 1*1, and then for each CI that modifies the impact of the violence change, expects each modification to be O (Logn).
But this problem card constant. but this problem card constant. but this problem card constant.
Finally, uoj a premium IO optimization before 2333.
#include <cstdio> #include <cstring> #include <cctype> #include <algorithm> #define REP (i,s,t) for (int. i=s;i<=t;i++) #define DWN (i,s,t) for (int i=s;i>=t;i--) using namespace std;typedef long long ll;const int Buf Fersize=1<<16;char Buffer[buffersize],*head,*tail;inline Char Getchar () {if (head==tail) {int L=fread (buf Fer,1,buffersize,stdin); Tail= (Head=buffer) +l; } return *head++;} inline int read () {int X=0,f=1;char c=getchar (); for (;! IsDigit (c); C=getchar ()) if (c== '-') f=-1; for (; IsDigit (c); C=getchar ()) x=x*10+c-' 0 '; return x*f;} #define S 1200000char pf[s],*o1=pf,*o2=pf+s; #define OT (x) (O1==o2?fwrite (Pf,1,s,stdout), * (O1=PF) ++=x:*o1++=x) inline void print (ll x) {static char s[20],*b;b=s;if (!X) *b++=48;for (; x;*b++=x%10+48,x/=10); for (; b--! =s;ot (*b));} const INT Maxn=1000010;int n,q;ll B[maxn],ans[maxn];int main () {n=read (); Q=read (); Rep (i,1,n) for (int j=i;j<=n;j+=i) B[j]++;while (q--) {int t=read (), X=read (), if (t==2) print (ans[x]), OT (' \ n '), else {int v=read (); for (int i=x;i<=n;i+=x) ans[i]+=v*b[i/x];}} Fwrite (pf,1,o1-pf,stdout); return 0;}
C Average
Obvious 01 score planning, two points to the answer then the question is converted to calculate how many successive sub-sequences and >0, discrete tree-like array to calculate the line.
Pay attention to the accuracy problem.
#include <cstdio> #include <cstring> #include <cctype> #include <cmath> #include <algorithm > #define REP (i,s,t) for (int. i=s;i<=t;i++) #define DWN (i,s,t) for (int i=s;i>=t;i--) using namespace Std;inline int read () {int X=0,f=1;char c=getchar (); for (;! IsDigit (c); C=getchar ()) if (c== '-') f=-1; for (; IsDigit (c); C=getchar ()) x=x*10+c-' 0 '; return x*f;} typedef long LONG Ll;const int maxn=100010;const double eps=1e-12;ll k;int n,a[maxn],c[maxn];int sumv[maxn];void Add (int x {for (; x<=n+1;x+=x&-x) sumv[x]++;} int sum (int x) {int res=0;for (; x;x-=x&-x) Res+=sumv[x];return Res;} Double b[maxn],tmp[maxn];ll check (double x) {memset (sumv,0,sizeof (SUMV)); Rep (i,1,n) b[i]= (a[i]-x) *1e10;rep (i,1,n) b[ I]+=b[i-1];rep (i,1,n) tmp[i]=b[i];tmp[n+1]=0.0;sort (tmp+1,tmp+n+2); Rep (i,1,n+1) if (Fabs (tmp[i]-tmp[i-1]) <eps) Tmp[i]=tmp[i-1];rep (i,0,n) C[i]=lower_bound (Tmp+1,tmp+n+2,b[i])-tmp;ll Ans=0;rep (i,1,n) {Add (C[i-1]); Ans+=sum (C[i ]);} return ans;} int main () {n=read (); SCANF ("%lld", &k);d ouble l=0.0,r=0.0;rep (i,1,n) R=max (R, (double) (A[i]=read ())); while (r-l>1e-10) {double mid= (l + R) *0.5;if (check (mid) >=k) L=mid;else R=mid;} printf ("%.6lf\n", l); return 0;}
D Little Q's Homework
The Hand (DA) pushes (Biao) the male (DA) type (FA) to G (n) =n*d (n), where D (n) represents an approximate number of n.
Set N=∏ (PI^CI), then D (n) =∏ (ci+1).
And then the problem is simple, because the range of the numbers is [1,10^7], the violence is engaged in the cycle, the linear sieve of the minimum quality factor on the line.
#include <cstdio> #include <cstring> #include <cctype> #include <algorithm> #define REP (i,s,t) for (int. i=s;i<=t;i++) #define DWN (i,s,t) for (int i=s;i>=t;i--) using namespace Std;typedef long long ll;inline ll Rea D () {ll x=0,f=1;char C=getchar (); for (;! IsDigit (c); C=getchar ()) if (c== '-') f=-1; for (; IsDigit (c); C=getchar ()) x=x*10+c-' 0 '; return x*f;} const int Maxn=10000010;const int Mod=1000000007;int pow (ll n,ll m) {ll ans=1;for (; m;m>>=1, (n*=n)%=mod) if (m&1 ) (Ans*=n)%=mod;return ans;} int Pri[maxn/10],d[maxn],cnt;bool vis[maxn];void init (int n) {d[1]=1;rep (i,2,n) {if (!vis[i]) Pri[++cnt]=i,d[i]=i;rep ( J,1,CNT) {if (i*pri[j]>n) break;vis[i*pri[j]]=1;if (i%pri[j]==0) {d[i*pri[j]]=d[i];break;} D[I*PRI[J]]=PRI[J];}}} int x1,a,b,c,k,a[maxn];ll M;int Main () {m=read (); X1=read (); A=read (); B=read (); C=read (); Init (c); A[x1]=1;int x=x1;ll Ans=1; (ans*=x1)%=mod;do {k++;x= (LL) x*a+b)%c+1; a[x]++;(ans*=x)%=mod;} while (a[x]==1&&k<m-1), if (k<m-1) {a[x]--;(ans*=pow (x,mod-2))%=mod;while (x1!=x) k--, m--, x1= ((LL) x1*a+b)%c+1;ll t=m/k,ct=1;m-=t*k;t--;d o {(a[x]+=t%mod)%=mod;if ( m) a[x]++,m--, (ans*=x)%=mod; (ct*=x)%=mod;x= ((LL) x*a+b)%c+1;} while (x!=x1);(Ans*=pow (ct,t))%=mod;} Dwn (i,c,2) {if (d[i]==i) (ans*=a[i]+1)%=mod;else (A[i/d[i]]+=a[i])%=mod, (A[d[i]]+=a[i])%=mod;} printf ("%lld\n", ans); return 0;}
51nod Algorithm Marathon 14