标签:ons logs sdn include ace 参考 ring names targe
思路:
找规律。参考了http://blog.csdn.net/harlow_cheng/article/details/71190999。
实现:
1 #include <iostream> 2 using namespace std; 3 const int mod = 1e9 + 7; 4 int main() 5 { 6 string s; 7 cin >> s; 8 int n = s.length(); 9 int cnt = 1; 10 int sum = 0; 11 for (int i = 0; i < n; i++) 12 { 13 if (s[i] == ‘a‘) cnt = cnt * 2 % mod; 14 else sum = (sum + cnt - 1) % mod; 15 } 16 cout << sum << endl; 17 return 0; 18 }
CF804B Minimum number of steps
标签:ons logs sdn include ace 参考 ring names targe
原文地址:http://www.cnblogs.com/wangyiming/p/7158204.html