Fibonacci

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

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.

 
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
 
Output
For each case output "Yes" or "No".
 
Sample Input
3
4
17
233
 
Sample Output
Yes
No
Yes
 
Source
题意:问一个数n,能否由斐波那契数列中的某些数乘积组成;
思路:打表,能组成的全弄出来;
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi (4*atan(1.0))
#define eps 1e-14
const int N=2e5+,M=4e6+,inf=1e9+,mod=1e9+;
const ll INF=1e18+;
map<ll,int>m;
ll f[N];
priority_queue<ll,vector<ll>,greater<ll> >q;
void init()
{
int pre=;
int now=;
f[]=;
f[]=;
for(int i=;i<=;i++)
f[i]=f[i-]+f[i-];
for(int i=;i<=;i++)
if(!m[f[i]])
q.push(f[i]),m[f[i]]=;
while(!q.empty())
{
ll v=q.top();
q.pop();
for(int i=;i<=;i++)
{
if(f[i]*v<inf&&!m[f[i]*v])
{
m[f[i]*v]=;
q.push(f[i]*v);
}
}
}
}
int main()
{
init();
int T;
scanf("%d",&T);
while(T--)
{
int n;
scanf("%d",&n);
if(m[n])
printf("Yes\n");
else
printf("No\n");
}
return ;
}

hdu 5167 Fibonacci 打表的更多相关文章

  1. HDU 5167 Fibonacci 筛法+乱搞

    题目链接: hdu: http://acm.hdu.edu.cn/showproblem.php?pid=5167 题意: 给你一个x,判断x能不能由斐波那契数列中的数相乘得到(一个数可以重复使用) ...

  2. hdu 5167 Fibonacci(预处理)

    Problem Description Following is the recursive definition of Fibonacci sequence: Fi=⎧⎩⎨01Fi−1+Fi−2i ...

  3. HDU 3117 Fibonacci Numbers(围绕四个租赁斐波那契,通过计++乘坐高速动力矩阵)

    HDU 3117 Fibonacci Numbers(斐波那契前后四位,打表+取对+矩阵高速幂) ACM 题目地址:HDU 3117 Fibonacci Numbers 题意:  求第n个斐波那契数的 ...

  4. hdu 1496 Equations hash表

    hdu 1496 Equations hash表 题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1496 思路: hash表,将原来\(n^{4}\)降 ...

  5. hdu 3117 Fibonacci Numbers 矩阵快速幂+公式

    斐波那契数列后四位可以用快速幂取模(模10000)算出.前四位要用公式推 HDU 3117 Fibonacci Numbers(矩阵快速幂+公式) f(n)=(((1+√5)/2)^n+((1-√5) ...

  6. HDU 1021 Fibonacci Again【打表找规律】

    Fibonacci Again Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  7. hdu 5104 素数打表水题

    http://acm.hdu.edu.cn/showproblem.php?pid=5104 找元组数量,满足p1<=p2<=p3且p1+p2+p3=n且都是素数 不用素数打表都能过,数据 ...

  8. HDU 5976 Detachment 打表找规律

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5976 Detachment Time Limit: 4000/2000 MS (Java/Other ...

  9. hdu Interesting Fibonacci

    Interesting Fibonacci Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

随机推荐

  1. 【python】__future__模块

    转自:http://www.jb51.net/article/65030.htm Python的每个新版本都会增加一些新的功能,或者对原来的功能作一些改动.有些改动是不兼容旧版本的,也就是在当前版本运 ...

  2. 160922、配置:spring通过profile或@profile配置不同的环境(测试、开发、生产)

    一.配置环境 applicationContext.xml中添加下边的内容(develop:开发环境,production:生产环境,test:测试环境) 注意:profile的定义一定要在文档的最下 ...

  3. Oracle之虚拟索引

    一.引言 DBA在日常维护管理数据库进行低性能SQL分析时,有时候需要通过创建索引对SQL进行优化,但有些时候我们创建的索引是否能用到?这个只能创建以后才能看出效果,但是在实际工作中,特别是对大表创建 ...

  4. JavaEE基础(十九)/异常和File

    1.异常(异常的概述和分类) A:异常的概述 异常就是Java程序在运行过程中出现的错误. B:异常的分类 通过API查看Throwable Error 服务器宕机,数据库崩溃等 Exception ...

  5. Mootools插件-闪烁的标题

    转自:http://www.cnblogs.com/see7di/archive/2012/10/09/2716024.html 回想起来,我已经好久没有写点啥了,尤其是关于Mootools方面的东西 ...

  6. 【转】在Eclipse中配置tomcat

    转载地址: http://kin111.blog.51cto.com/738881/163096 为了在Eclipse中进行struts2的测试,才发现自己机器上的Eclipse没有集成Tomcat, ...

  7. TelephonyManager类:Android手机及Sim卡状态的获取

    TelephonyManager这个类很有用,可以得到很多关于手机和Sim卡的信息. 直接上注释后的代码,请享用 package net.sunniwell.app;import android.ap ...

  8. Unity中实现List类型的自定义GUI(ReorderableList)

    感谢韩同学提供的资源 Unity本身提供了float,int,vector3..等类型字段的gui接口,而对于集合类型一般要自己硬写. 官方提供了一个List的自定义GUI,但使用起来非常复杂 Uni ...

  9. Winsock系列函数 及 Socket通信流程

    Socket是一种网络通信机制   Winsock系列函数   1. Socket 创建socket   2. Connect 尝试连接远端Socket   3. Send 在某个Socket 向远端 ...

  10. Uva 12186 工人的请愿书

    题目链接:https://uva.onlinejudge.org/external/121/12186.pdf 题意: 给出一个树状关系图,公司里只有一个老板编号为0,其他人员从1开始编号.除了老板, ...