本文共 959 字,大约阅读时间需要 3 分钟。
#include #include #include #include #include #include #include #include #include #include #include #include #define tree int o,int l,int r#define lson o<<1,l,mid#define rson o<<1|1,mid+1,r#define lo o<<1#define ro o<<1|1#define ULL unsigned long long#define LL long long#define UI unsigned int#define inf 0x7fffffff#define eps 1e-7#define N 1000009#define M 20009using namespace std;int T,n,m,k,t;char str[N];int dp[13][1110010];int main(){#ifndef ONLINE_JUDGE freopen("ex.in","r",stdin);#endif while (scanf("%d%d",&n,&m)!=EOF) { memset(dp,0,sizeof(dp)); scanf("%s",str); n=strlen(str); str[n+m]='\0'; for(int i=0; i =n-1)str[i+1]='0';//要先处理! for(int j=0;j<13&&i-j>=0;j++) { if(str[i-j]-'0') sum+=(1<<(j)); if(i>=n-1&&dp[j][sum]) { str[i+1]=str[dp[j][sum]]; } dp[j][sum]=i+1; } } cout< <
转载于:https://www.cnblogs.com/sbaof/p/3148599.html