Fibonacci Again
来源:互联网 发布:深入浅出node.js 微盘 编辑:程序博客网 时间:2024/05/18 20:37
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.
#include <iostream>using namespace std;int f (int n);int main (){ int count = 0, num; while(count <=3) { cin >> num; if(f(num)%3 == 0) cout << "YES" << endl; else cout << "NO" << endl; count ++; } return 0;}int f (int n){ switch(n) { case 0: return 7; break; case 1: return 11; break; } return f(n-1)+f(n-2);}
阅读全文
0 0
- Fibonacci Again
- Fibonacci Again
- Fibonacci Again
- Fibonacci Again
- Fibonacci Again
- Fibonacci Again
- Fibonacci Again
- Fibonacci Again
- Fibonacci Again
- Fibonacci Again
- Fibonacci Again
- Fibonacci Again
- Fibonacci Again
- Fibonacci Again
- Fibonacci Again
- Fibonacci Again
- Fibonacci Again
- Fibonacci Again
- 冒泡排序算法
- fragment多层切套fragment出现试图不显示的原因
- PBOC/EMV-交易流程详解--POS与卡片的数据交互进行分析
- java常用的2中加密密码方式MD5和Encrypt
- Android开发中简化findViewById的几种方法
- Fibonacci Again
- screencap
- 基础的jquery
- Linux 下curl模拟Http 的get or post请求。
- java 反射
- spring boot的表单验证
- 静态变量的简单 和 strtok 的使用实现 标识符的作用域
- 无法打开SQL Server的连接 provider:Named Pipes Provider,error:40
- 【mysql 字符串截取】SUBSTRING_INDEX用法