范围 内的斐波那契的数不多,求出范围内的数,再暴力枚举即可。

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
#define N 1000000000
__int64 foci[200];
int fc=0,cnt;
__int64 tmp[50]; void init(){
foci[0]=0; foci[1]=1;
fc=1;
for(fc=2;foci[fc-1]<=N;fc++){
foci[fc]=foci[fc-1]+foci[fc-2];
// cout<<foci[fc]<<endl;
}
fc=fc-1;
} bool dfs(__int64 n,int pos){
if(n==1LL) return true;
for(int i=pos;i<=cnt;i++){
if(n%tmp[i]==0&&dfs(n/tmp[i],i))
return true;
}
return false;
} int main(){
init();
int T,i;
__int64 n;
scanf("%d",&T);
while(T--){
scanf("%I64d",&n);
if(n==0||n==1LL){
printf("Yes\n");
continue;
}
i=3; cnt=0;
for(i;i<=fc;i++){
if(n%foci[i]==0)
tmp[++cnt]=foci[i];
}
bool flag=dfs(n,1);
if(flag)
printf("Yes\n");
else printf("No\n");
}
return 0;
}

  

HDU 5167的更多相关文章

  1. HDU 5167 Fibonacci 筛法+乱搞

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

  2. HDU 5167(map + 暴力)

    题意:给出一个数n,问n能否是斐波那契数列中数的乘积 先刷选 斐波那契数列,然后就枚举 #include <cstdio> #include <cstring> #includ ...

  3. hdu 5167 Fibonacci 打表

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

  4. hdu 5167 Fibonacci(预处理)

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

  5. hdu 5167(dfs)

    Fibonacci Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total S ...

  6. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  7. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  8. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  9. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

随机推荐

  1. 约瑟夫环问题的链表解法和数学解法(PHP)

    约瑟夫环问题 一群猴子排成一圈.按1,2,-,n依次编号.然后从第1仅仅開始数,数到第m仅仅,把它踢出圈.从它后面再開始数,再数到第m仅仅.在把它踢出去-.如此不停的进行下去.直到最后仅仅剩下一仅仅猴 ...

  2. JQuery常用的api[最好是系统地学习一下《锋利的JQuery》]

    text http://api.jquery.com/text/ Get the combined text contents of each element in the set of matche ...

  3. 【Codeforces 258E】 Devu and Flowers

    [题目链接] http://codeforces.com/contest/451/problem/E [算法] 容斥原理 [代码] #include<bits/stdc++.h> usin ...

  4. C - Ilya and Sticks(贪心)

    Problem description In the evening, after the contest Ilya was bored, and he really felt like maximi ...

  5. ComboBoxEdit 添加键值

    ComboBoxEdit combo = new ComboBoxEdit(); var coll = combo.Properties.Items; coll.BeginUpdate(); try ...

  6. 推荐10个超棒的jQuery工具 提示插件

    脚本之家 http://www.jb51.net/article/28525.htm

  7. spring boot的项目结构问题

    问题:spring boot项目能够正常启动,但是在浏览器访问的时候会遇到404的错误,Whitelable Error Page 404 分析及解决方案:首先Application文件要放在项目的外 ...

  8. windwo下载完nvm无法执行node

    安装node版本管理工具之NVM.安装方法:见链接. window安装完后,下载node后,无法执行node.见图(图片从网上找的). 最后问题原因是,1.nvm安装时,安装目录中存在空格. 解决办法 ...

  9. sass揭秘之@mixin,%,@function(转载)

    因为文章内含有很多sass代码,如需自己动手查看编译结果,推荐使用sassmeister这款在线编译工具,方便你阅读学习. 在阅读本文章之前,请先确认你已经阅读了上篇文章sass揭秘之变量,不然会给你 ...

  10. NOIP2016 天天爱跑步 线段树合并_桶_思维题

    竟然独自想出来了,好开心 Code: #include<bits/stdc++.h> #define setIO(s) freopen(s".in","r&q ...