#include <stdio.h>
int main()
{
int n,i;
int a[45]={2,3};
scanf("%d",&n);
for (i=2;i<45;i++)
a[i]=a[i-1]+a[i-2];
for(i=0;i<45;i++)
{
if(n==a[i])
printf("Bob!");
break;
}
if(i==45)
printf("Bob!");
return 0;
}
或c++版:
#include <iostream>
using namespace std;
int main()
{
int i;
__int64 n,fib[45] = {2,3};
for (i = 2;i < 45;i++)
fib[i] = fib[i-1] + fib[i-2];
while(cin >> n && n)
{
for(i = 0;i < 45;i++)
if(fib[i] == n)
{
cout << "Second win
";
break;
}
if(i == 45)
cout << "First win
";
}
return 0;
}