15HD_OJ题——Fibonacci Again

来源:互联网 发布:qq飞车布鲁斯沃特数据 编辑:程序博客网 时间:2024/05/21 13:06

/*
 * Copyright (c) 2014, 烟台大学计算机学院
 * All rights reserved.
 * 文件名称:test.cpp
 * 作    者:李晓凯
 * 完成日期:2015年 5 月 24 日
 * 版 本 号:v1.0
 *
 * 问题描述:
 * 输入描述:
 * 程序输出:

 */

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

012345

Sample Output

nonoyesnonono
代码:

#include <iostream>using namespace std;int main(){    long a;    while (cin>>a)    {        if(a%8==2||a%8==6)            cout<<"yes"<<endl;        else            cout<<"no"<<endl;    }    return 0;}


解题思路:这个题需要找好规律,规律就是8个为一循环,而当F(n)除以8余2或6的时候,就能被三整除,当发现这个规律后,题目就简单了。。。。

0 0
原创粉丝点击