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. 对比其它软件方法评估敏捷和Scrum

    一般来说,选择一种软件开发方法,更像是加入一个邪教组织,而不像是做出了一个技术决策.许多公司甚至从未试图去评估这些方法,而仅仅是盲目采用最流行的方法,这就造成了如今五花八门的各种敏捷方法.因此本文将使 ...

  2. git log用法【转】

    转自:http://www.cnblogs.com/gbyukg/archive/2011/12/12/2285419.html PHP技术交流群 170855791 git log 查看提交记录,参 ...

  3. C++:FMC 错误

    1.generated debug assertion -- File: docsingl.cpp Line: 215 MFC程序vs2008编译通过,运行时出错,无法打开,提示f:\dd\xxxx的 ...

  4. python:配置文件configparser

    #-*- coding:utf8 -*- # Auth:fulimei import configparser #第一个标签 conf=configparser.ConfigParser() conf ...

  5. 每日一九度之 题目1039:Zero-complexity Transposition

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3372 解决:1392 题目描述: You are given a sequence of integer numbers. Zero-co ...

  6. JavaScript DOM 编程艺术(第2版)读书笔记(2)

    JavaScript 语法 注释 单行注释:// 多行注释:/* */ "<!--"可以用作单行注释,由于和HTML的"<!--  -->"多 ...

  7. android内存优化相关1

    第一种策略,是释放显示相关的内存.这是我们针对系统APP采用的一种调优策略. 图形内容,俗称位图是非常占用内存的,针对位图,我们采用异步加载的方法,将位图内容信息和位图的状态信息分别进行存储,将内容信 ...

  8. DNA Sorting 分类: POJ 2015-06-23 20:24 9人阅读 评论(0) 收藏

    DNA Sorting Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 88690 Accepted: 35644 Descrip ...

  9. MySql5.7-多源复制(多主单从)

    1.1.主库配置 my.cnf   #确保唯一 server-id=1 #作为Master要开启binlog log-bin=mysql-bin #binlog format有三种形式:Stateme ...

  10. JAVA基础知识之IO-File类

    File类介绍 File是java.io包下面的一个类,代表与平台无关的文件或者目录.JAVA中,无论文件还是目录,都可以看作File类的一个对象.File类能对文件或目录新建,删除,获取属性等操作, ...