HDU Fibonacci Again

Fibonacci Again

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 39   Accepted Submission(s) : 31

Font: Times New Roman | Verdana |
Georgia

Font Size: ← →

Problem Description

There are another kind of Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2).

Input

Input consists of a sequence of lines, each containing an integer n. (n < 1,000,000).

Output

Print the word "yes" if 3 divide evenly into F(n).

Print the word "no" if not.

Sample Input

0
1
2
3
4
5

Sample Output

no
no
yes
no
no
no

Author

Leojay

找规律的题目。

把f(n)分裂开就能够得到规律。

AC代码:

#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
    long n;
    while(scanf("%ld",&n) != EOF)
       if (n%8==2 || n%8==6)
           printf("yes\n");
       else
           printf("no\n");
    return 0;
}

运行结果:


时间: 2024-07-30 00:42:39

HDU Fibonacci Again的相关文章

[HDU] Fibonacci Check-up

这是链接 结论破题,浪费了我三张纸,结论居然只和斐波那契数列有关,有趣 推导过程太多不写了qwq,虽然推导很简单,但是有个坑点,很难想到将 $ S_i $ 最终化为 $ F_i $ 表示. 结论是 \[ S_i = F_{n*2} \] 所以这道题我们只需要求斐波那契数就行了,是不是很简单啊qwq. #include<iostream> #include<algorithm> #include<cstdio> #include<cstring> #inclu

hdu 5167 Fibonacci(DFS)

hdu 5167 Fibonacci 问题描述 斐波那契数列的递归定义如下: Fi=???01Fi?1+Fi?2i = 0i = 1i > 1 现在我们需要判断一个数是否能表示为斐波那契数列中的数的乘积. 输入描述 有多组数据,第一行为数据组数T(T≤100,000). 对于每组数据有一个整数n,表示要判断的数字. 0≤n≤1,000,000,000 输出描述 对于每组数据,如果可以输出"Yes",否则输出"No". 输入样例 3 4 17 233 输出样例

HDU 1588 Gauss Fibonacci(矩阵高速幂+二分等比序列求和)

HDU 1588 Gauss Fibonacci(矩阵高速幂+二分等比序列求和) ACM 题目地址:HDU 1588 Gauss Fibonacci 题意: g(i)=k*i+b;i为变量. 给出k,b,n,M,问( f(g(0)) + f(g(1)) + ... + f(g(n)) ) % M的值. 分析: 把斐波那契的矩阵带进去,会发现这个是个等比序列. 推倒: S(g(i)) = F(b) + F(b+k) + F(b+2k) + .... + F(b+nk) // 设 A = {1,1,

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

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5018 题目意思:给出在 new Fibonacci 中最先的两个数 A 和 B(也就是f[1] = A, f[2] = B),通过这条式子f[n] = f[n-1] + f[n-2],问 C 是否在这条 new Fibonacci sequence 内.(1 <= A, B, C <= 1 000 000 000) 首先,要想到 C 有可能是 A 或者 B,这种情况也是属于在这个序列范围内的. 还

矩阵十题【三】 HDU 1588 Gauss Fibonacci

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1588 题目大意:先要知道一组斐波那契数列 i 0 1 2 3 4 5 6 7 f(i) 0 1 1 2 3 5 8 13 下面给你一组数: k,b,n,M 现在知道一组公式g(i)=k*i+b:(i=0,1,2,3...n-1) 让你求出 f(g(i)) 的总和(i=01,2,3,...,n-1),比如给出的数据是2 1 4 100 2*0+1=1   f(1)=1 2*1+1=3   f(3)=2

HDU 4786 Fibonacci Tree 最小生成树变形

思路: 这题比赛的时候想了好久,最后队友机智的想到了. 不过那时不是我敲的,现在敲的1A. 想好就容易了. 直接把1或者0当做边的权值,然后按边从小到大排序,然后算最小生成用到了几条白边,然后再按边从大到小排序,然后再算白边用了几条.然后最小和最大需要用到的白边都算出来了.如果在这最小最大区间中存在那个啥数列的话就是Yes,否则就是No. 为什么在这区间里面就是对的呢?刚开始我也想了好久,然后发现,因为白边权值是1,然后黑边是0,然后假设用到白边最小的是6,最大的是10,那么,我们可以用黑边去替

HDU - 1848 - Fibonacci again and again

先上题目: Fibonacci again and again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4964    Accepted Submission(s): 2072 Problem Description 任何一个大学生对菲波那契数列(Fibonacci numbers)应该都不会陌生,它是这样定义的:F(1)=1;F

HDU - 1588 Gauss Fibonacci (矩阵快速幂+二分求等比数列和)

Description Without expecting, Angel replied quickly.She says: "I'v heard that you'r a very clever boy. So if you wanna me be your GF, you should solve the problem called GF~. " How good an opportunity that Gardon can not give up! The "Prob

hdu 2814 Interesting Fibonacci

Interesting Fibonacci Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 712    Accepted Submission(s): 137 Problem Description In mathematics, the Fibonacci numbers are a sequence of numbers name