HDU 1021 - Fibonacci Again】的更多相关文章

http://acm.hdu.edu.cn/showproblem.php?pid=1021 Fibonacci Again Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 29201    Accepted Submission(s): 14148 Problem Description There are another kind…
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1021 Fibonacci Again Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 70782    Accepted Submission(s): 32417 Problem Description There are another ki…
#include<iostream> using namespace std; int main() { int n; while(cin>>n) { if((n+1)%4==3) cout<<"yes"<<endl; else cout<<"no"<<endl; } return 0; } There are another kind of Fibonacci numbers: F(0) =…
Fibonacci Again Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 66450    Accepted Submission(s): 30760 Problem Description There are another kind of Fibonacci numbers: F(0) = 7, F(1) = 11, F(n)…
链接:传送门 题意:现在给出 Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2).问第 n 项能不能整除 3 思路:F(n) % 3 == 0 可以推导出 F(n) = ( F(n-1)%3 + F(n-2)%3 ) % 3 ,直接打个表判断 F(n) 是否为 0 即可 /*********************************************************************…
找规律,分析让 F[N] 每一项对 3 取余的余数: 1,2,0, 2,2,1,0, 1,1,2,0, 2,2,1,0, 1,1,2,0, 2,2,1,0 ......... 显然循环了 #include <iostream> using namespace std; int main() { int n; while(cin>>n){ ==) cout<<"yes"<<endl; else cout<<"no&qu…
同余问题 基本定理: 若a,b,c,d是整数,m是正整数, a = b(mod m), c = d(mod m) a+c = b+c(mod m) ac = bc(mod m) ax+cy = bx+dy(mod m) -同余式可以相加 ac = bd(mod m) -同余式可以相乘 a^n = b^n(mod m) f(a) = f(b)(mod m) if a = b(mod m) and d|m then a = b(mod d) eg: 320 = 20(mod 100) and d =…
BUPT2017 wintertraining(16) #5 A HDU - 1021 题意 There are another kind of Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2). 输入n,若F(n)能被3整除,输出yes,否则no 题解 列一下前几项F(i)可以发现n%4==2则是yes,否则no. 代码 #include <cstdio> #include <cstring…
HDU 3117 Fibonacci Numbers(斐波那契前后四位,打表+取对+矩阵高速幂) ACM 题目地址:HDU 3117 Fibonacci Numbers 题意:  求第n个斐波那契数的前四位和后四位.  不足8位直接输出. 分析:  前四位有另外一题HDU 1568,用取对的方法来做的.  后四位能够用矩阵高速幂,MOD设成10000即可了. 代码: /* * Author: illuz <iilluzen[at]gmail.com> * Blog: http://blog.c…
斐波那契数列后四位可以用快速幂取模(模10000)算出.前四位要用公式推 HDU 3117 Fibonacci Numbers(矩阵快速幂+公式) f(n)=(((1+√5)/2)^n+((1-√5)/2)^n)/√5 假设F[n]可以表示成 t * 10^k(t是一个小数),那么对于F[n]取对数log10,答案就为log10 t + K,此时很明显log10 t<1,于是我们去除整数部分,就得到了log10 t 再用pow(10,log10 t)我们就还原回了t.将t×1000就得到了F[n…