Problem Description
Loading...
Problem Analysis
For a string consisting entirely of 1s, let f(n) denote the number of possibilities when its length is n. The following cases apply:
When the length is 1, i.e. “1”, no merging is possible, so there is only 1 possibility;
When the length is 2, i.e. “11”, there is only one way to merge: the string can become “11” or “2”, giving 2 possibilities;
When the length is n, appending a 1 to a string of length n-1 gives f(n-1) cases, or its (n-1)-th 1 and n-th 1 merge into 2, giving f(n-2) possibilities; in total there are f(n-2)+f(n-1) possibilities.
So we can use the Fibonacci idea
Because the numbers are too large
we need to use string simulation
cpp
| |
Problem link: HDU 1865 1sting