http://acm.hdu.edu.cn/showproblem.php?pid=5018

任意给你三个数,让你判断第三个数是否在以前两个数为开头组成的Fibonacci 数列中。

直接暴力

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <queue>
#include <vector>
#include<set>
#include <iostream>
#include <algorithm>
using namespace std;
#define RD(x) scanf("%d",&x)
#define RD2(x,y) scanf("%I64d%I64d",&x,&y)
#define clr0(x) memset(x,0,sizeof(x))
typedef long long LL;
LL a,b,c,d;
void work()
{
RD2(a,b);scanf("%I64d",&c);
bool flag = false;
if(a == c || b == c){
cout<<"Yes"<<endl;
return;
}
while(b < c){
d = b+a;
if(d == c){
cout<<"Yes"<<endl;
return;
}
else if(d > c){
cout<<"No"<<endl;
return;
}
a = b,b = d;
}
cout<<"No"<<endl;
return;
}
int main() {
int _;
RD(_);
while(_--){
work();
}
return 0;
}

hdu 5018的更多相关文章

  1. BestCoder10 1001 Revenge of Fibonacci(hdu 5018) 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5018 题目意思:给出在 new Fibonacci 中最先的两个数 A 和 B(也就是f[1] = A ...

  2. hdu 5018 Revenge of Fibonacci

    大水题 #include<time.h> #include <cstdio> #include <iostream> #include<algorithm&g ...

  3. hdu 5018 Revenge of GCD

    题意: 给你两个数:X和Y  .输出它们的第K大公约数.若不存在输出 -1 数据范围: 1 <= X, Y, K <= 1 000 000 000 000 思路: 它俩的公约数一定是gcd ...

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

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

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

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

  6. hdu 4859 海岸线 Bestcoder Round 1

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

  7. HDU 4569 Special equations(取模)

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

  8. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  9. HDU 1796How many integers can you find(容斥原理)

    How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

随机推荐

  1. orientdb 学习

    简介 OrientDB 是一款 NoSQL 数据库.是一种文档-图数据库.即:既具有文档数据库的特性,又具有图数据库的功能. 端口 2424  OrientDB 监听 二进制 访问的的端口 (即:通过 ...

  2. 自定义事件 js

    // 原理如下// 创建 类型为HTMLEvents的事件 var evt = document.createEvent("HTMLEvents"); // 初始化 自定义eee ...

  3. Android热修复(HotFix)实战

    线上的BUG一直是程序员头疼的问题.有时候仅仅是因为几行的代码,就能让你的用户损失严重.谷歌在Android Studio 加入了Insttan Run 机制.通过Apk动态加载的技术实现了应用非安装 ...

  4. hibernate经常报的几个不起眼的错误, 都是因为不细心或者手滑了输入有误造成了

    最近会经常用到hibernate了, 也经常报错, 看着屏幕上一根大红条是非常不爽的, 这几天集合了一下经常报的错误, 整合一下放到这里, 以后再出现这个错误直接去解决就好了 1, org.hiber ...

  5. ALL ANY SOME 这样解释好理解很多

    --All:对所有数据都满足条件,整个条件才成立,例如:5大于所有返回的id select * from #A where 5>All(select id from #A) go --Any:只 ...

  6. CookiesHelper

    /// <summary> ///CookiesHelper 的摘要说明 /// </summary> public class CookiesHelper { public ...

  7. 现代编译原理--第二章(语法分析之LR(1))

    (转载请表明出处  http://www.cnblogs.com/BlackWalnut/p/4472772.html) 前面已经介绍过LL(1),以及如何使用LL(1)文法.但是LL(K)文法要求在 ...

  8. 2015湖南湘潭 D 二分

    2015湖南湘潭第七届大学生程序设计比赛 D题 Fraction Accepted : 133   Submit : 892 Time Limit : 1000 MS   Memory Limit : ...

  9. mupdf编译snprintf冲突问题

    mupdf-1.6-source\thirdparty\jbig2dec\config_win32.h //#  define snprintf _snprintf

  10. 跨页传值c#

    Application (4)URL地址中的参数 (5)通过隐藏字段来传递数据 (6)Server.Transfer (7)通过序列化对象 (8)........ 下面就分别一一介绍: (1)使用Se ...