1 条题解
-
0
找循环节
#include<bits/stdc++.h> using namespace std; long long n,i,t,x,y,m; bool ccf[70005][20]; namespace IO{ char ibuf[(1<<20)+1],*iS,*iT; #if ONLINE_JUDGE #define gh() (iS==iT?iT=(iS=ibuf)+fread(ibuf,1,(1<<20)+1,stdin),(iS==iT?EOF:*iS++):*iS++) #else #define gh() getchar() #endif #define reg register inline long long read(){ reg char ch=gh(); reg long long x=0; reg char t=0; while(ch<'0'||ch>'9') t|=ch=='-',ch=gh(); while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=gh(); return t?-x:x; } } using IO::read; void write(int x) { if(x<0){ putchar('-'); write(-x); return; } if(x>=10)write(x/10); putchar(x%10+'0'); } bool check(int x,int y) { for(int i=1;i<=n;i++) if(ccf[x][i]!=ccf[y][i]) return 0; return 1; } int main() { n=read(); m=read(); for(i=1;i<=n;i++)ccf[0][i]=read(); while(t<=pow(2,16)+1){ t++; if(ccf[t-1][n])ccf[t][1]=!ccf[t-1][1]; else ccf[t][1]=ccf[t-1][1]; for(i=n;i>1;i--) if(ccf[t-1][i-1])ccf[t][i]=!ccf[t-1][i]; else ccf[t][i]=ccf[t-1][i]; for(i=1;i<t;i++) if(check(t,i)){ x=i,y=t; break; } if(t==m){ for(i=1;i<=n;i++)write(ccf[t][i]),puts(""); return 0; } } for(i=1;i<=n;i++)write(ccf[(m-1)%(y-x)+1][i]),puts(""); return 0; }
- 1
信息
- ID
- 169
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 8
- 标签
- (无)
- 递交数
- 108
- 已通过
- 15
- 上传者