#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>using namespace std;const int MOD = 20200821,N = 5000010;
long long a[N]; // i个字母能够组成的子串的个数 0:0 1: 1 2: 3 3: 6 4: 10 ... int main(){string s;cin >> s;int l = s.length();a[0] = 0;for(int i = 1; i <= 10; i ++){a[i] = a[i - 1] + i;a[i] %= MOD; }int cnt = 0;int ans = 0; for(int i = 0; i < l; i ++){if(s[i] == '1'){cnt++; }else if(s[i] == '0' && cnt > 0){ // 前面有连续的1 ans += a[cnt];ans %= MOD;cnt = 0; } }//特判 if(cnt > 0){ // 末尾是1 ans += a[cnt]; } cout << ans << endl;return 0;
}
本文发布于:2024-01-29 07:12:22,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170648354713593.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |