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; } ---来自腾讯云社区的---饶文津
微信扫一扫打赏
支付宝扫一扫打赏