即是費氏數列。
P.S. 小心,會超過int的範圍喔!
C++(0.008)
/*******************************************************/
/* UVa 12459 Bees' ancestors */
/* Author: Maplewing [at] knightzone.studio */
/* Version: 2012/10/20 */
/*******************************************************/
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
long long f[85] = { 1, 1 };
int n;
for( int i = 2 ; i <= 80 ; i++ )
f[i] = f[i-1] + f[i-2];
while( scanf( "%d", &n ) != EOF && n != 0 ){
printf( "%lld\n", f[n] );
}
return 0;
}