BUPT2017 wintertraining(16) #5 A
HDU - 1021
题意
There are another kind of Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2). 输入n,若F(n)能被3整除,输出yes,否则no
题解
列一下前几项F(i)可以发现n%4==2则是yes,否则no.
代码
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
int n;
while(~scanf("%d",&n)){
if(n%4==2)puts("yes");
else puts("no");
}
return 0;
}