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.
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
- 15HD_OJ题——Fibonacci Again
- 15HD_OJ题——Rightmost Digit
- 15HD_OJ——sort
- 15HD_OJ题——人见人爱A^B
- hdu1021——Fibonacci Again
- hdu1021——Fibonacci Again
- HDU1021——Fibonacci Again
- 15HD_OJ——The area
- 15HD_OJ——{A} + {B}
- 15HD_OJ——The Last Practice
- 15HD_OJ——母牛的故事
- 15HD_OJ——Common Subsequence
- 15HD_OJ——最少拦截系统
- 15HD_OJ——Max Sun
- 15HD_OJ——FatMouse's Speed
- HDU—1021—Fibonacci Again—【入门题】
- hdu1848——Fibonacci again and again(SG函数)
- hdu1848—Fibonacci again and again(博弈论sg)
- js对象标签
- Class.forName() 和 ClassLoader.loadClass()的区别?
- OC语言中的类和对象
- Unity3D的四种坐标系
- oracle 导入/导出数据库结构和数据【命令方式】
- 15HD_OJ题——Fibonacci Again
- 第11周 项目2 职员有薪水了(1)
- XMPP协议 搭建Tigase开发环境
- Android数据库SQLite
- 硬编码学习(五)
- C语言中的动态内存--堆和栈
- 第11周 项目2-2 职员有薪水了(2)
- 欢迎使用CSDN-markdown编辑器
- 如何让 Git 使用 HTTP 代理服务器