题意:
思路:
打表找规律,变换过程会有一个周期,总会变回初始状态。进一步发现周期为第一个大于等于字符串长的的2的幂次数。然后暴力跑一遍就行了。(可以过100%,但感觉不像正解,有无大佬教教)
代码:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 998244353;
const ll de = 4e10;
const int maxn = 2e6 + 7;
map<string , int >mp;
string s[2] , str;
ll n , t;
string cal(string now , int t){
s[0] = now;
s[1] = now;
int v = 1;
for(int i = 1; i <= t; i ++){
for(int j = 1; j < s[0].size(); j ++){
s[v][j] = ((s[v ^ 1][j] - '0') ^ (s[v ^ 1][j - 1] - '0')) + '0';
}
v ^= 1;
}
return s[v ^ 1];
}
int main(){
scanf("%d%d",&n,&t);
cin>>str;
int T = 1;
for(int i = 2; i <= 20000; i *= 2){
if(i >= n){
T = i;
break;
}
}
/*
s[0] = str;
s[1] = str;
int v = 1 , T = 1;
for(int i = 1; i <= 20000; i ++){
for(int j = 1; j < s[0].size(); j ++){
s[v][j] = ((s[v ^ 1][j] - '0') ^ (s[v ^ 1][j - 1] - '0')) + '0';
}
if(s[v] == str){
T = i;
break;
}
// cout<<s[v]<<endl;
v ^= 1;
}
*/
//printf ("%d %d\n",T , t % T);
cout<<cal(str , t % T);
}