HDU 5167
范围 内的斐波那契的数不多,求出范围内的数,再暴力枚举即可。
#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的更多相关文章
- HDU 5167 Fibonacci 筛法+乱搞
题目链接: hdu: http://acm.hdu.edu.cn/showproblem.php?pid=5167 题意: 给你一个x,判断x能不能由斐波那契数列中的数相乘得到(一个数可以重复使用) ...
- HDU 5167(map + 暴力)
题意:给出一个数n,问n能否是斐波那契数列中数的乘积 先刷选 斐波那契数列,然后就枚举 #include <cstdio> #include <cstring> #includ ...
- hdu 5167 Fibonacci 打表
Fibonacci Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Proble ...
- hdu 5167 Fibonacci(预处理)
Problem Description Following is the recursive definition of Fibonacci sequence: Fi=⎧⎩⎨01Fi−1+Fi−2i ...
- hdu 5167(dfs)
Fibonacci Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total S ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
随机推荐
- 复制DropDownList
DropDownList ddlA; ListItem[] ar = new ListItem[ddlB.Items.Count]; ddlB.Items.CopyTo(ar,0); ddlA.Dat ...
- SQL SERVER读书笔记:执行计划
执行计划对性能影响甚大. 系统是怎么得出一个号的执行计划的?主要是依赖于准确的统计信息.统计信息准确的前提下,执行语句重用性高,可避免频繁编译,这也有助于提高性能. 但如果怀疑统计信息不够准确,可以强 ...
- DDos攻击篇
DDoS(Distributed Denial of Service,分布式拒绝服务)攻击的主要目的是让指定目标无法提供正常服务,甚至从互联网上消失,是目前最强大.最难防御的攻击之一. 1.1. SY ...
- LightOJ--1149--Factors and Multiples(二分图好题)
Factors and Multiples Time Limit: 2000MS Memory Limit: 32768KB 64bit IO Format: %lld & %llu ...
- poj--2186--Popular Cows (scc+缩点)
Popular Cows Time Limit : 4000/2000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other) Total ...
- TF-IDF算法--关键词句和文本集中每篇文章相关度计算
关键词句和文本集每篇文章相关度计算:假设语料库中有几万篇文章,每篇文章的长度不一,你任意输入关键词或句子,通过代码以tf-idf值为准检索出来相似度高的文章. 1.TF-IDF概述 TF-IDF是一种 ...
- Monad Maybe
在上一篇, 我们创建了第一个Monad,Indentity<T>, 它可能是最简单的Monad, 使我们可以快速了解Monad的模式,而不用陷入细节.接下来我们创建一个有用的Monad, ...
- FlappyBird模拟(不完整版本)
FlappyBird模拟(不完整版本) 准备材料 land地 sky天 pipe管道 bird小鸟 Land.js function Land(info) { this.x = info.x; thi ...
- javascirpt之 this、apply、call、bind
this.apply.call.bind 这又是一个面试经典问题~/(ㄒoㄒ)/~~也是 ES5中众多坑中的一个,在 ES6 中可能会极大避免 this 产生的错误,但是为了一些老代码的维护,最好还是 ...
- javascript中的原型对象
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...