一道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 consis

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/02 10:07:25
一道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 consis

一道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 consis
一道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

一道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 consis
因为f(n)只有七中取值0-6,系数a对应7个,b对应7个,A * f(n - 1) + B * f(n - 2)) 只有49个不同值,为一个周期,只要开一个数组储存这49个值mod 7的余数就好了,然后用n%49,来算