【HDU 1021】Fibonacci Again(找规律)

2020-06-02 12:18:57 浏览数 (3)

题意

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.

代码

代码语言:javascript复制
#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;
}

0 人点赞