HDU 1021[Fibonacci Again]规律

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1021

题目大意:首两项为7,11的斐波那契数列。若第n项能被3整除,输出yes,否则输出no

关键思想:模三加法情况有限,找规律。

代码如下:

#include <iostream>
using namespace std;

int main(){
	int n;
	while(cin>>n)
	if(n%8==2||n%8==6)cout<<"yes"<<endl;
	else cout<<"no"<<endl;
	return 0;
}

  

时间: 2024-10-17 20:49:05

HDU 1021[Fibonacci Again]规律的相关文章

hdu 1021 Fibonacci Again(变形的斐波那契)

传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1021 Fibonacci Again Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 70782    Accepted Submission(s): 32417 Problem Description There are another ki

HDU 1021.Fibonacci Again【规律】【不可直接求】【8月18】

Fibonacci Again Problem Description There are another kind of Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2). Input Input consists of a sequence of lines, each containing an integer n. (n < 1,000,000). Output Print the word &q

hdu 1021 Fibonacci Again 找规律

Fibonacci Again Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 51448    Accepted Submission(s): 24346 Problem Description There are another kind of Fibonacci numbers: F(0) = 7, F(1) = 11, F(n)

HDU 1021 Fibonacci Again 数学题

Problem Description There are another kind of Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2). Input Input consists of a sequence of lines, each containing an integer n. (n < 1,000,000). Output Print the word "yes" if

杭电 HDU 1021 Fibonacci Again

Fibonacci Again Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 41156    Accepted Submission(s): 19705 Problem Description There are another kind of Fibonacci numbers: F(0) = 7, F(1) = 11, F(n)

HDU 1021 - Fibonacci Again

找规律,分析让 F[N] 每一项对 3 取余的余数: 1,2,0, 2,2,1,0, 1,1,2,0, 2,2,1,0, 1,1,2,0, 2,2,1,0 ......... 显然循环了 1 #include <iostream> 2 using namespace std; 3 int main() 4 { 5 int n; 6 while(cin>>n){ 7 if(n%4==2) cout<<"yes"<<endl; 8 else

hdu 5167 Fibonacci(DFS)

hdu 5167 Fibonacci 问题描述 斐波那契数列的递归定义如下: Fi=???01Fi?1+Fi?2i = 0i = 1i > 1 现在我们需要判断一个数是否能表示为斐波那契数列中的数的乘积. 输入描述 有多组数据,第一行为数据组数T(T≤100,000). 对于每组数据有一个整数n,表示要判断的数字. 0≤n≤1,000,000,000 输出描述 对于每组数据,如果可以输出"Yes",否则输出"No". 输入样例 3 4 17 233 输出样例

HDU 4786 Fibonacci Tree 最小生成树变形

思路: 这题比赛的时候想了好久,最后队友机智的想到了. 不过那时不是我敲的,现在敲的1A. 想好就容易了. 直接把1或者0当做边的权值,然后按边从小到大排序,然后算最小生成用到了几条白边,然后再按边从大到小排序,然后再算白边用了几条.然后最小和最大需要用到的白边都算出来了.如果在这最小最大区间中存在那个啥数列的话就是Yes,否则就是No. 为什么在这区间里面就是对的呢?刚开始我也想了好久,然后发现,因为白边权值是1,然后黑边是0,然后假设用到白边最小的是6,最大的是10,那么,我们可以用黑边去替

HDU - 1848 - Fibonacci again and again

先上题目: Fibonacci again and again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4964    Accepted Submission(s): 2072 Problem Description 任何一个大学生对菲波那契数列(Fibonacci numbers)应该都不会陌生,它是这样定义的:F(1)=1;F