持续更新中……
从哪里跌倒,从哪里爬起!
B
建立主席树,对每次询问算出答案,然后二分位置判断
代码:略
H
容易发现答案大时一定是k+1或者k+2,n若被k+1整除,则答案是k+1,反之是k+2
其次发现答案至少是k+1,然后可以将剩余的分配,然后每次往每一堆里塞一个就行,设n=a(k+1)+b,答案是k+1+[b/a]
但要注意的是如果n小于k+1则每个颜色不同,要特判一下
#include<bits/stdc++.h> using namespace std; const int N=1e6+7; int n,k,x; char nn[N],xx[N]; void check(int a,int b) { if(a==b)puts("Correct, but it doesn't necessarily mean that you can win the Turing Award."); if(a<b)puts("Wrong, don't cheat me, you are too far away from the Turing Award.\n1"); if(a>b)puts("Wrong, don't cheat me, you are too far away from the Turing Award.\n0"); } int main() { scanf("%s%d%s",nn+1,&k,xx+1); if(strlen(xx+1)>=4) {puts("Wrong, don't cheat me, you are too far away from the Turing Award.\n1");return 0;} for(int i=1;i<=strlen(xx+1);++i)x=x*10+xx[i]-'0'; if(strlen(nn+1)>5) { for(int i=1;i<=strlen(nn+1);++i)n=(n*10+nn[i]-'0')%(k+1); if(!n)check(k+1,x);else check(k+2,x); } else{ for(int i=1;i<=strlen(nn+1);++i)n=n*10+nn[i]-'0'; if(n<k+1)check(n,x); else if(n%(k+1)==0)check(k+1,x); else check(k+2+(n%(k+1)-1)/(n/(k+1)),x); } }
I
数位DP,注意Nim获胜条件,2^m枚举子集,f[i][S][j]表示从高到低dp到第i位,目前被卡上限的集合是S,低位向这位进j次,注意j的范围是[0,m-1]
代码:略