Problem Toki’s function
Posted 2aptx4869
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Problem Toki’s function相关的知识,希望对你有一定的参考价值。
#include <bits/stdc++.h> #define ll long long using namespace std; int n, mod = 1000000007; char s[200005]; int main() { cin >> n >> s + 1; ll ans = 0; int flag = 0; for (int i = 1; s[i]; ++i) { if (s[i] == ‘1‘) ans = (ans + (ll)(1 + i) * i / 2 % mod * i % mod) % mod, flag = i; else if (flag) ans = (ans + (ll)(i + i - flag + 1) * flag / 2 % mod * flag % mod) % mod; } cout << ans << ‘ ‘; return 0; }
以上是关于Problem Toki’s function的主要内容,如果未能解决你的问题,请参考以下文章
Jessica's Reading Problem POJ 3320(尺取)
CodeForces - 742B Arpa’s obvious problem and Mehrdad’s terrible solution
CodeForces 742B Arpa’s obvious problem and Mehrdad’s terrible solution (暴力枚举)