UVa 900 Brick Wall Patterns
無所不在的費波納西數列。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* UVa 900 Brick Wall Patterns | |
* Last Modified: 2009.11.27 | |
* Author: chchwy | |
*/ | |
#include<cstdio> | |
int main() | |
{ | |
long long int fib[51]; | |
fib[0] = fib[1] = 1; | |
for (int i = 2; i <= 50; ++i) | |
fib[i] = fib[i - 1] + fib[i - 2]; | |
int in; | |
while (scanf("%d", &in) == 1) | |
{ | |
if (in == 0) | |
break; | |
printf("%lld\n", fib[in]); | |
} | |
return 0; | |
} |
留言
張貼留言