hdu 5018
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的更多相关文章
- BestCoder10 1001 Revenge of Fibonacci(hdu 5018) 解题报告
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5018 题目意思:给出在 new Fibonacci 中最先的两个数 A 和 B(也就是f[1] = A ...
- hdu 5018 Revenge of Fibonacci
大水题 #include<time.h> #include <cstdio> #include <iostream> #include<algorithm&g ...
- hdu 5018 Revenge of GCD
题意: 给你两个数:X和Y .输出它们的第K大公约数.若不存在输出 -1 数据范围: 1 <= X, Y, K <= 1 000 000 000 000 思路: 它俩的公约数一定是gcd ...
- 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 ...
- HDU 4006The kth great number(K大数 +小顶堆)
The kth great number Time Limit:1000MS Memory Limit:65768KB 64bit IO Format:%I64d & %I64 ...
- HDU 1796How many integers can you find(容斥原理)
How many integers can you find Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d ...
随机推荐
- Python内置类型性能分析
Python内置类型性能分析 timeit模块 timeit模块可以用来测试一小段Python代码的执行速度. class timeit.Timer(stmt='pass', setup='pass' ...
- scala 建模
// train multinomial logistic regression val lr = new LogisticRegressionWithLBFGS() .setIntercept(tr ...
- etcd 集群恢复
七个节点,挂了5个,etcd无法访问 参考: https://coreos.com/etcd/docs/latest/op-guide/recovery.html 此次我只恢复了v3的数据 在存活的节 ...
- Java 命令行运行参数
Java在运行已编译完成的类时,是通过java虚拟机来装载和执行的,java虚拟机通过操作系统命令JAVA_HOME"bin"java –option 来启动,-option为虚拟 ...
- [leetcode]381. Insert Delete GetRandom O(1) - Duplicates allowed常数时间插入删除取随机值
Design a data structure that supports all following operations in average O(1) time. Note: Duplicate ...
- 转载博客:rabbitmq
原文出处:http://www.cnblogs.com/sam-uncle/p/9202933.html 假设有这一些比较耗时的任务,按照上一次的那种方式,我们要一直等前面的耗时任务完成了之后才能接着 ...
- linux配置网络
1.配置网络信息 linux系统的第一块网卡信息 /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE 设备名 ONBOOT 系统启动后是否自动启动网卡设备 ...
- ssh登录忽略known_hosts列表
编辑 ~/.ssh/config 如果不存在,可以先创建,并且要注意其读写权限 mkdir -p ~/.ssh touch ~/.ssh/config ~/.ssh/config 文件内容如下 Log ...
- .NET Utils 辅助类
using System;using System.Diagnostics;using System.IO;using System.Reflection;using System.Runtime.I ...
- MVC,MVP,MVVM区别联系
本质上都是MVC,MVC在不同技术中的应用衍生出MVP,MVVM MVC:b/s MVP:c/s,尤其winform MVVM:wpf http://www.codeproject.com/Artic ...