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. 实现溢出文本eclipsis的解决

    实现溢出文本eclipsis的解决:overflow:hidden;text-overflow:ellipsis; white-space:nowrap; 如:<a href="&qu ...

  2. URLconf

    URLconf 浏览者通过在浏览器的地址栏中输入网址请求网站,对于Django开发的网站,由哪一个视图进行处理请求,是由url匹配找到的 配置 在test3/settings.py中通过ROOT_UR ...

  3. python并行编程

    一.编程思想 并行编程的思想:分而治之,有两种模型 1.MapReduce:将任务划分为可并行的多个子任务,每个子任务完成后合并得到结果 例子:统计不同形状的个数. 先通过map进行映射到多个子任务, ...

  4. scala 2.11.6 卸载 2.12.6 安装

    .yum remove scala .安装scala wget -O scala-.rpm https://downloads.lightbend.com/scala/2.12.6/scala-2.1 ...

  5. UVa 1592 Database(巧用map)

    Peter studies the theory of relational databases. Table in the relational database consists of value ...

  6. URL去重

    import socket dictlist ={}; def ReadHost(): hosts = []; obn = open('d:/sss.txt', 'rb'); for line in ...

  7. OAuth2.0 Owin 授权问题

    http://www.cnblogs.com/dudu/p/4569857.html OAuth2.0 一.什么是OAuth OAuth是一个关于授权(Authorization)的开放网络标准,目前 ...

  8. [z]kafka相关资料

    http://my.oschina.net/ielts0909/blog/93190 http://www.iteye.com/magazines/107 http://blog.csdn.net/h ...

  9. [freeCodeCamp] solution to JUGGLING ASYNC

    Here's the official solution in case you want to compare notes: var http = require('http') var bl = ...

  10. Mathtype使用技巧

    1. 打开/关闭MathType窗口 Alt+Ctrl+q:插入inline公式   Ctrl+S:更新公式到Word相应位置 Alt+F4:保存并关闭MathType窗口,返回Word. 2. 公式 ...