本文共 929 字,大约阅读时间需要 3 分钟。
Fibonacci AgainTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 44439 Accepted Submission(s): 21214Problem DescriptionThere are another kind of Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2).InputInput consists of a sequence of lines, each containing an integer n. (n < 1,000,000).OutputPrint the word "yes" if 3 divide evenly into F(n).Print the word "no" if not.Sample Input012345Sample Outputnonoyesnonono
解题思路:实在没啥说的,就是找寻环节,直接上代码吧,其实还可以用矩阵乘法做,感觉有点麻烦,但是为了学会矩阵乘法,我觉定要用矩阵做一下,当然这是待会的事情了,嘿嘿:
/*2015 - 8 - 13Author: ITAK今日的我要超越昨日的我,明日的我要胜过今日的我,以创作出更好的代码为目标,不断地超越自己。*/#include#include using namespace std;int data[30];int main(){ /* 打表看一下,找寻环节 data[0] = 7; data[1] = 11; for(int i=2; i<30; i++) data[i] = data[i-1]+data[i-2]; for(int i=0; i<30; i++) if(data[i]%3 == 0) cout< <
转载地址:http://ujfkm.baihongyu.com/