2010年9月17日 星期五

ACM 11000 - Bee

#include <stdio.h>
int main()
{
while (1)
{
long n, i;
scanf("%ld", &n);
if (n < 0) break;
long female[2], recode, male = 0,total = 0;
female[0] = 0, female[1] = 1;
if(n == 0)
{
printf("0 1\n");
continue;
}
else
for(i=1 ; i<=n ; i++)
{
male = female[1] + male;
recode = female[1] ,female[1] += female[0], female[0] = recode;
total = male + female[1];
}
printf("%ld %ld\n", male, total);
}
return 0;
}


回目錄
回首頁

沒有留言 :

張貼留言

Related Posts Plugin for WordPress, Blogger...