早教吧作业答案频道 -->数学-->
一道ACM题求大神指导是怎么推出周期的?ProblemDescriptionAnumbersequenceisdefinedasfollows:f(1)=1,f(2)=1,f(n)=(A*f(n-1)+B*f(n-2))mod7.GivenA,B,andn,youaretocalculatethevalueoff(n).InputTheinputconsis
题目详情
一道ACM题求大神指导是怎么推出周期的?
Problem Description A number sequence is defined as follows:f(1) = 1,f(2) = 1,f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7.Given A,B,and n,you are to calculate the value of f(n).Input The input consists of multiple test cases.Each test case contains 3 integers A,B and n on a single line (1
Problem Description A number sequence is defined as follows:f(1) = 1,f(2) = 1,f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7.Given A,B,and n,you are to calculate the value of f(n).Input The input consists of multiple test cases.Each test case contains 3 integers A,B and n on a single line (1
▼优质解答
答案和解析
因为f(n)只有七中取值0-6,系数a对应7个,b对应7个,A * f(n - 1) + B * f(n - 2)) 只有49个不同值,为一个周期,只要开一个数组储存这49个值mod 7的余数就好了,然后用n%49,来算
看了 一道ACM题求大神指导是怎么...的网友还看了以下:
点点收敛为什么不一定连续?函数序列{fn}点点收敛到f,已知:fn连续,为什么f不一定连续?函数序 2020-04-07 …
A→B表示A是B的同学,且有A→B,B→C那么,A→C一定正确吗?请说明理由 2020-04-26 …
为什么选C一名英国学者称:“英国人把议会比作政坛大本钟——除了还在那里闹出点动静外,没有更大用处” 2020-05-16 …
I don't know how to deal with customers _____ the 2020-05-17 …
已知f(x)之一原函数为sin3x,求∫f'(x)dx书上的答案是∫f'(x)dx=f(x)+Cf 2020-05-19 …
delicious中的c在单词中发什么音?c一般是K或者S的发音,但是看音标,c貌似发ʃ,怎么回事 2020-07-23 …
求解一题证明题!高数设f(x)与g(x)在[a,b]上连续,在(a,b)上可导,f(a)=f(b) 2020-08-01 …
已知函数y=g(x)在区间(-3,0)上是减函数,且函数y=g(x-3)是偶函数,试比较g(-5) 2020-08-01 …
如果f(x)是定义在R上的函数,那么f(x)一定可以用一个奇函数与一个偶函数的和来表示吗?为什么? 2020-08-01 …
为什么F-C烷化时需要过量的苯方能制的单烷基化产物 2020-10-31 …