HUDJ 1021 Fibonacci Again

Fibonacci Again

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 36028    Accepted Submission(s): 17385

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 3 divide evenly into F(n).

Print the word "no" if not.

Sample Input

0
1
2
3
4
5

Sample Output

no
no
yes
no
no
no
#include<iostream>
#include<cstring>
using namespace std;

int main()
{
	int n;
	while(cin>>n)
	{
		if(n==2)   cout<<"yes\n";
		else  if((n-2)%4==0)    cout<<"yes\n";
		else   cout<<"no\n";
	}

	return 0;
}
时间: 2024-08-02 17:03:26

HUDJ 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]规律

题目链接: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"<

杭电 1021 Fibonacci Again

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1021 解题思路:根据之前发现斐波那契数列的规律,即为f(n)能被3整除当且仅当n能被4整除. 于是联想到这道题目,它只是改变了f(0)和f(1)的值,肯定也一样有规律可以寻找 f(0)=7; f(1)=11; f(2)=18;能整除3 f(3)=29; f(4)=47; f(5)=76; f(6)=123;能整除3 f(7)=200; f(8)=323; f(9)=523; f(10)=846;能整

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

1021 Fibonacci Again (hdoj)

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 数学题

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): 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

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)

1021 Fibonacci Again

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