早教吧作业答案频道 -->数学-->
一道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题求大神指导是怎么...的网友还看了以下:
1.求圆的周长1)r=3.52)d=2.82.求圆的直径1)r=1.22)r=6.53)c=6.2 2020-04-12 …
已知函数f(x)=1-cosx+sin(x+π/6) 1求f(x)的最小正周期,2,记△ABC的内 2020-05-16 …
分度头的手柄转一周,装夹在主轴上的工件转()。A.1周B.20周C.40周D.1/40周 2020-06-07 …
指出下列问题中的变量和常量1.水中涟漪(圆形水波)不断扩大,记它的半径为r,圆周长为c,圆周率指出 2020-06-14 …
请教一个题,如下:A点是变轨开关,可连B或C,小圈周长1.5米,最大圈(整个外圈)周长3米,开始A 2020-06-25 …
火车绕大小圈变轨开关请教一个题,如下:A点是变轨开关,可连B或C,小圈周长1.5米,最大圈周长3米 2020-06-30 …
小张上周工作a小时,每小时的工资为b元,本周他的工作时间比上周减少10%,而每小时的工资数额增加1 2020-07-23 …
一.判断1.圆的周长是直径的π(pai)倍2.圆的周长为C,半径为r,那么圆周率π等于C除以2r3 2020-08-01 …
f(x)是定义域为R的奇函数,它的最小正周期为2,则:f(1)+f(2)+f(3)…+f(1995 2020-08-03 …
说说下列几组作文题在写作重点或写作范围上有什么区别.(1)a.《我的家庭》b.《我家的周末》c.说说 2020-11-14 …