hdu 1021】的更多相关文章

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…
同余问题 基本定理: 若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 =…
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…
刚开始直接按题意来写,WA了,唉,果然经验不够..然后开始找规律,本来一看到这种题,第一反应就是规律题,然后看看题意,貌似没啥规律哦!就像当时学DP一样,总是想当然被智商压制了啊喂! #include<iostream> #include<cstdio> using namespace std; int main(){ int k; while(scanf("%d",&k)!=EOF){ if((k-2)%4!=0) cout<<"…
#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) =…
找规律,分析让 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…
参考自:https://www.cnblogs.com/ECJTUACM-873284962/p/6404504.html Fibonacci Again Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 58267    Accepted Submission(s): 27275 Problem Description There are…
题意是说在给定的一种满足每一项等于前两项之和的数列中,判断第 n 项的数字是否为 3 的倍数. 斐波那契数在到第四十多位的时候就会超出 int 存储范围,但是题目问的是是否为 3 的倍数,也就是模 3 值为 0 ,考虑到余数只有0,1,2,而且每项由前两项求和得到,也就是说余数一定会出现循环的规律,从首项开始,前 8 项模 3 的结果是:1 2 0 2 2 1 0 1,接下来的两项模 3 的结果仍是 1 2 ,那么整个序列就呈现出以 8 为周期的特点,只要模 8 的结果为 3 或者 7 就输出…
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)…