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

#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. 使用filezella服务器安装ftp

    使用FileZilla配置FTP站点,可参考以下步骤: 1.打开Filezilla Server服务端: 点击[Edit]->[Users],或者点击如下图标新增用户. 2.添加FTP帐号后,设 ...

  2. php pdo具体操作

    0x01:测试PDO是否安装成功 运行如下代码,如果提示参数错误,说明PDO已经安装,如果说明对象不存在,则修改PHP配置文件php.ini,取消php_pdo_yourssqlserverhere. ...

  3. HTML不熟悉方法总结

    1. onblur   属性在元素失去焦点时触发. 2. onfocus 属性在元素获得焦点时触发. 3.addEventlistener 事件监听 4.focus() 方法用于给予该元素焦点.这样用 ...

  4. JS——BOM操作(基本用法与实现:open()、close()、scrollTop等了解)

    (1)window.open() 定义和用法 open() 方法用于打开一个新的浏览器窗口或查找一个已命名的窗口 语法 window.open(URL,name,specs,replace) [默认填 ...

  5. 带中横线的日期格式在iOS手机系统上 转换时间戳NaN问题

    类似于 '2019-04-01 14:13:00' 这样的日期格式转换时间戳在iOS手机上是无法转换的,需要先处理日期格式成 '2019/04/01 14:13:00' var str = '2019 ...

  6. PowerDesigner 逆向工程 Could not Initialize JavaVM!

    原项目的大量的表,使用PowerDesigner 进行逆向工程.提示Could not Initialize JavaVM! 网上找到原因,PowerDesigner 不可以使用64位JDK环境! 有 ...

  7. 重载(overload)和重写(override)的对比(笔试经常出)

    Day04_SHJavaTraing_4-6-2017 1.重载(overload):    ①权限修饰符(public private 默认):        无关    ②返回值类型:       ...

  8. ML一:python的KNN算法

    (1):list的排序算法: 参考链接:http://blog.csdn.net/horin153/article/details/7076321 示例: DisListSorted = sorted ...

  9. max 宏定义取消:error C2589: error C2059: 语法错误 : “::”

    原文链接:http://blog.csdn.net/danelumax2/article/details/9172465有修改! 一:关于Pcl和WIndef的冲突: 1. 错误输出 ./zlibra ...

  10. yii处理cookie

    /** * 设置用户cookie会话 */ public function setCookie() { //set loginName $cookies = Yii::app()->reques ...