Promi_38

cf 805D

Jan 13th, 2021
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3.  
  4. int main()
  5. {
  6.     char s[1000009];
  7.     scanf("%s", s);
  8.    
  9.     int i, j, c = 0, k = 0;
  10.     for(i = strlen(s) - 1; i >= 0; i--)
  11.     {
  12.         if(s[i]=='b') c++;
  13.         else
  14.         {
  15.             k += c;
  16.             c *= 2;
  17.             k %= 1000000007;
  18.             c %= 1000000007;
  19.         }
  20.     }
  21.     printf("%d\n", k);
  22. }
Advertisement
Add Comment
Please, Sign In to add comment