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

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

直接暴力

  1. #include <cstdio>
  2. #include <cstdlib>
  3. #include <cmath>
  4. #include <cstring>
  5. #include <string>
  6. #include <queue>
  7. #include <vector>
  8. #include<set>
  9. #include <iostream>
  10. #include <algorithm>
  11. using namespace std;
  12. #define RD(x) scanf("%d",&x)
  13. #define RD2(x,y) scanf("%I64d%I64d",&x,&y)
  14. #define clr0(x) memset(x,0,sizeof(x))
  15. typedef long long LL;
  16. LL a,b,c,d;
  17. void work()
  18. {
  19. RD2(a,b);scanf("%I64d",&c);
  20. bool flag = false;
  21. if(a == c || b == c){
  22. cout<<"Yes"<<endl;
  23. return;
  24. }
  25. while(b < c){
  26. d = b+a;
  27. if(d == c){
  28. cout<<"Yes"<<endl;
  29. return;
  30. }
  31. else if(d > c){
  32. cout<<"No"<<endl;
  33. return;
  34. }
  35. a = b,b = d;
  36. }
  37. cout<<"No"<<endl;
  38. return;
  39. }
  40. int main() {
  41. int _;
  42. RD(_);
  43. while(_--){
  44. work();
  45. }
  46. return 0;
  47. }

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. 在windows 2008 R2中SQl Server 2008中代理启动失败的一个原因总结

    启动SQL代理的时候报错如下: 关调用实时(JIT)调试而不是此对话框的详细信息,请参见此消息的结尾. ************** 异常文本 **************System.NullRef ...

  2. 树莓派Zero W添加音频输出

    编译:陈拓 chentuo@ms.xab.ac.cn 2018.06.07/2018.07.14 原文:Adding Basic Audio Ouput to Raspberry Pi Zero ht ...

  3. JS中数组的创建方法

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  4. godaddy nginx https 配置

    一. 生成秘钥key,运行: $ openssl genrsa -des3 -out server.key 2048 1 会有两次要求输入密码,输入同一个即可 输入密码 然后你就获得了一个server ...

  5. 参数错误导致bug

    1.网站参数与数据库参数名字不一致(大小写). 2.参数漏掉一个字母(characterno写成了charaterno).

  6. in文件注意事项及详细解释

    lammps做分子动力学模拟时,需要一个输入文件(input script),也就是in文件,以及关于体系的原子坐标之类的信息文件(data file)和势文件(potential file).lam ...

  7. Java中spring读取配置文件的几种方法

    Spring读取配置XML文件分三步: 一.新建一个Java Bean: package springdemo; public class HelloBean { private String hel ...

  8. 内部存储 openFileInputStream openFileOutputStream

    package com.qianfeng.gp08_day24_internalstorage; import java.io.FileInputStream; import java.io.File ...

  9. 演示Spring框架的JDBC模板的简单操作

    1. 步骤一:创建数据库的表结构 create database spring_day03; use spring_day03; create table t_account( id int prim ...

  10. MSVCR90D.dll

    http://stackoverflow.com/questions/218747/msvcr90d-dll-not-found-in-debug-mode-with-visual-c-2008 I ...