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 ...
随机推荐
- 2016.04.13,英语,《Vocabulary Builder》Unit 13
cord, from the Latin word for 'heart'. concord, ['kɑːŋkɔːrd] n. 和睦, 公约 con-,'with'. discord, ['dɪskɔ ...
- 关于jetty服务器默认首页和端口设置
一.jetty服务器部署.启动成功后,在浏览器输入http://localhost:8080/ 可以直接访问到jetty欢迎首页. 这是因为在Jetty包中默认带了一个test.war的应用,在${J ...
- [.Net] 导出Excel中身份证等数字串的解决方式
public static void DataTableToExcel(System.Data.DataTable dtData, String FileName) { GridView dgExpo ...
- POJ3087 Shuffle'm Up
题目: 现有字符串s1.s2.s12,其中s1.s2的长度为len,s12的长度为2*len. 是否可以通过一些操作使s1和s2转换合并成s12? 变换的操作规则如下: 假设s1=11111,s2=0 ...
- POJ 3122 二分
大致题意: 就是公平地分披萨pie 我生日,买了n个pie,找来f个朋友,那么总人数共f+1人 每个pie都是高为1的圆柱体,输入这n个pie的每一个尺寸(半径),如果要公平地把pie分给每一个人(就 ...
- Android View事件分发与传递
在Android中,人们主要通过手指与系统交互.Android把所有的touch事件都被封装成MotionEvent来进行处理,其中包括了手指点击的位置,时间等信息.其事件类型主要包括:ACTION_ ...
- Monad的重点
Monad是非常强有力的概念,在介绍Monad是什么和如何工作的之前,我们应该先确认Monad能解决什么问题.Monad是各种编程问题的的 meta solution,它不是某种特定问题的解决方案,我 ...
- 第五课: - Stack / Unstack / Transpose函数
第 5 课 我们将简要介绍 stack 和 unstack 以及 T (Transpose)函数. 在用pandas进行数据重排时,经常用到stack和unstack两个函数.stack的意思是堆 ...
- javascript中对象属性搜索原则
为什么通过对象就能访问到原型中的属性或者方法? 属性搜索原则: 1 首先会在对象本身查找有没有该属性,如果有直接返回 2 如果没有,此时就会在构造函数中查找通过this给对象添加的成员中有没有,如果有 ...
- Android CollapsingToolbarLayout Toolbar的title覆盖问题
CollapsingToolbarLayout 里: app:titleEnabled="true" app:title="Hello" Toolbar 里: ...