Fibonacci Strings | 프로그래밍의 벗 PivotOJ
PivotOJ

Fibonacci Strings

시간 제한: 1000ms메모리 제한: 1024MB출처: Programmeringsolympiaden 2016 — katt3BOJ 21352

문제

Aron likes Fibonacci numbers. He likes them so much he actually got bored of the numbers themselves and decided to invent other combinatorial objects based on them instead.

His first invention is the Fibonacci string. We call a string consisting of only letters aa and bb, with exactly nn letters aa without any two consecutive letters aa a Fibonacci string of the nn:th order.

Given a string XX of aa:s and bb:s, compute the sum of orders of all Fibonacci strings that are substrings of XX. Note that if a string XX appears multiple times, its order should be counted once for every occurance.

입력

The sample judge reads input in the following format:

  • line 11: N
  • line 22: X

출력

The judge writes a single line containing the return value of fibonacci(N, X).

예제

예제 1

입력
6
abaaba
출력
12
코드를 제출하려면 로그인하세요.