hdu-5167 Fibonacci
来源:互联网 发布:python量化论坛 编辑:程序博客网 时间:2024/05/20 16:12
链接地址:http://acm.hdu.edu.cn/showproblem.php?pid=5167
Fibonacci
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 474 Accepted Submission(s): 126
Problem Description
Following is the recursive definition of Fibonacci sequence:
Fi=⎧⎩⎨01Fi−1+Fi−2i = 0i = 1i > 1
Now we need to check whether a number can be expressed as the product of numbers in the Fibonacci sequence.
Now we need to check whether a number can be expressed as the product of numbers in the Fibonacci sequence.
Input
There is a number T shows there are T test cases below. (T≤100,000 )
For each test case , the first line contains a integers n , which means the number need to be checked.
0≤n≤1,000,000,000
For each test case , the first line contains a integers n , which means the number need to be checked.
Output
For each case output "Yes" or "No".
Sample Input
3417233
Sample Output
YesNoYes
#include<stdio.h>#include<iostream>#include<math.h>#include<stdlib.h>#include<ctype.h>#include<algorithm>#include<vector>#include<string>#include<queue>#include<stack>#include<set>#include<map>#include <sstream>#include <time.h>#include <utility>#include <malloc.h>using namespace std;__int64 p[100];int T;__int64 n;int main(){ p[0] = 0; p[1] = 1; for (int i = 2; i <= 46; i++) p[i] = p[i - 1] + p[i - 2]; set<__int64> q; set<long long> ::iterator it; q.clear(); q.insert(0); q.insert(1); for(it=q.begin();it!=q.end();it++) { for(int j=3;j<=45;j++) { int tt = *it; __int64 tmp = tt*p[j]; if (tmp <= 1000000000) q.insert(tmp); } } cin>>T; while (T--) { int ok=0; cin>>n; if (q.find(n) != q.end()) cout << "Yes" << endl; else cout << "No" << endl; } return 0;}
0 0
- hdu-5167 Fibonacci
- hdu 5167 Fibonacci
- HDU 5167 Fibonacci
- 【预处理】 HDU 5167 Fibonacci
- HDU 5167 Fibonacci
- hdu 5167-Fibonacci
- HDU 5167Fibonacci
- 【DFS】hdu 5167 Fibonacci
- hdu 5167 Fibonacci(DFS)
- hdu 5167 Fibonacci(dfs)
- hdu 5167 Fibonacci(dfs)
- hdu 5167 Fibonacci【思维】【递归】
- HDU-Fibonacci
- hdu Fibonacci
- Fibonacci HDU
- HDU Fibonacci
- HDU 5167 Fibonacci (DFS + Fib数列)
- HDU - 5166 - Missing number && 5167 - Fibonacci
- c++ 模板的一些
- LeetCode:Remove Duplicates from Sorted Array II
- OpenGL基础图形编程
- eclipse导出jar文件再将它转换成exe可执行文件详解
- [暖手][学习阶段-各路杂题][HDU-1163]Eddy's digital Roots
- hdu-5167 Fibonacci
- Assetbundle创建与加载
- UBUNTU13 + Skyeye1.3.5
- Event-driven programming for Android
- win10下wamp环境搭建(包括整套软件、安装DOC讲解、数据库清理等)
- JPDA#1:使用JDI写一个调试器
- PSAM卡相关知识整理
- What is Reactive Programming?
- Java 透明和不规则 Swing 窗口