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 ...
随机推荐
- 在windows 2008 R2中SQl Server 2008中代理启动失败的一个原因总结
启动SQL代理的时候报错如下: 关调用实时(JIT)调试而不是此对话框的详细信息,请参见此消息的结尾. ************** 异常文本 **************System.NullRef ...
- 树莓派Zero W添加音频输出
编译:陈拓 chentuo@ms.xab.ac.cn 2018.06.07/2018.07.14 原文:Adding Basic Audio Ouput to Raspberry Pi Zero ht ...
- JS中数组的创建方法
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...
- godaddy nginx https 配置
一. 生成秘钥key,运行: $ openssl genrsa -des3 -out server.key 2048 1 会有两次要求输入密码,输入同一个即可 输入密码 然后你就获得了一个server ...
- 参数错误导致bug
1.网站参数与数据库参数名字不一致(大小写). 2.参数漏掉一个字母(characterno写成了charaterno).
- in文件注意事项及详细解释
lammps做分子动力学模拟时,需要一个输入文件(input script),也就是in文件,以及关于体系的原子坐标之类的信息文件(data file)和势文件(potential file).lam ...
- Java中spring读取配置文件的几种方法
Spring读取配置XML文件分三步: 一.新建一个Java Bean: package springdemo; public class HelloBean { private String hel ...
- 内部存储 openFileInputStream openFileOutputStream
package com.qianfeng.gp08_day24_internalstorage; import java.io.FileInputStream; import java.io.File ...
- 演示Spring框架的JDBC模板的简单操作
1. 步骤一:创建数据库的表结构 create database spring_day03; use spring_day03; create table t_account( id int prim ...
- MSVCR90D.dll
http://stackoverflow.com/questions/218747/msvcr90d-dll-not-found-in-debug-mode-with-visual-c-2008 I ...