ps | |
---|---|
링크 | acmicpc.net/… |
출처 | BOJ |
문제 번호 | 15485 |
문제명 | a^ib^jc^k |
레벨 | 골드 2 |
분류 |
dp |
시간복잡도 | O(n) |
인풋사이즈 | n<=1,000,000 |
사용한 언어 | Python 3.11 |
제출기록 | 33212KB / 204ms |
최고기록 | 204ms |
해결날짜 | 2023/07/17 |
"""Solution code for "BOJ 15485. \(a^ib^jc^k\)".
- Problem link: https://www.acmicpc.net/problem/15485
- Solution link: http://www.teferi.net/ps/problems/boj/15485
"""
MOD = 1_000_000_007
def main():
S = input()
count_a = count_b = count_c = 0
for c in S:
if c == 'a':
count_a = (count_a * 2 + 1) % MOD
elif c == 'b':
count_b = (count_b * 2 + count_a) % MOD
elif c == 'c':
count_c = (count_c * 2 + count_b) % MOD
print(count_c)
if __name__ == '__main__':
main()