Advertisement
askarulytarlan

Untitled

May 6th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MOD = int(1e9) + 7;
  5. long long cnt, ans;
  6.  
  7. int main(){
  8. cin >> s;
  9. for(int i = s.size() - 1; i >= 0; i--){
  10. if(s[i] == 'b')
  11. cnt++;
  12. cnt %= MOD;
  13. else
  14. ans += cnt;
  15. ans %= MOD;
  16. cnt *= 2;
  17. cnt %= MOD;
  18. }
  19. cout << ans;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement