照著題目將公蜜蜂和母蜜蜂的隻數一代一代算出即可,算的時候要記得第一隻的母蜜蜂是不死的。
C++(0.000)
/*******************************************************/
/* UVa 11000 Bee */
/* Author: Maplewing [at] knightzone.studio */
/* Version: 2015/12/01 */
/*******************************************************/
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
long long int maleBee[70] = {0}, femaleBee[70] = {1};
for( int i = 1 ; i < 70 ; ++i ){
maleBee[i] = maleBee[i-1] + femaleBee[i-1];
femaleBee[i] = maleBee[i-1] + 1;
}
int N;
while( scanf("%d", &N) != EOF && N != -1 ){
printf("%lld %lld\n", maleBee[N], maleBee[N] + femaleBee[N]);
}
return 0;
}