def calcular_jogadas(entrada):
MOD = 1000000007
contagem_b = 0
jogadas = 0
indice = len(entrada) - 1
while indice >= 0:
letra = entrada[indice]
if letra != 'b':
jogadas = (jogadas + contagem_b) % MOD
contagem_b = (2 * contagem_b) % MOD
else:
contagem_b = (contagem_b + 1) % MOD
indice -= 1
return jogadas
entrada = input()
resultado = calcular_jogadas(entrada)
print(resultado)
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
const int M = 1e9 + 7;
int n;
long long ans, cnt;
char a[N];
int main() {
scanf("%s", a + 1);
n = strlen(a + 1);
for (int i = n; i >= 1; i--) {
if (a[i] == 'a') {
ans = (ans + cnt) % M;
cnt = cnt * 2 % M;
}
else if (a[i] == 'b'){
cnt++;
}
// cout << cnt << ' ' << ans << ' ' << i << endl;
}
printf("%lld", ans);
return 0;
}
Count of integers | Differences of the permutations |
Doctor's Secret | Back to School |
I am Easy | Teddy and Tweety |
Partitioning binary strings | Special sets |
Smallest chosen word | Going to office |
Color the boxes | Missing numbers |
Maximum sum | 13 Reasons Why |
Friend's Relationship | Health of a person |
Divisibility | A. Movement |
Numbers in a matrix | Sequences |
Split houses | Divisible |
Three primes | Coprimes |
Cost of balloons | One String No Trouble |
Help Jarvis! | Lift queries |
Goki and his breakup | Ali and Helping innocent people |