标签:imp pac text sample main sse java ati otto
题目是这样的:
2 5
package package1;
import java.util.Scanner;
public class Main
{
public static int A,B,n;
public static final int Maxn = 100;
public static int[] Arr = new int[Maxn];
public static void main(String[] args)
{
Scanner cin = new Scanner(System.in);
while(cin.hasNext())
{
A = cin.nextInt();
B = cin.nextInt();
n = cin.nextInt();
if(A == 0 && B == 0 && n == 0)
{
return;
}
int T;
T = init();
Arr[0] = Arr[T];
System.out.println(Arr[n%T]);
}
}
public static int init()
{
Arr[1] = 1;
Arr[2] = 1;
int i;
for(i = 3 ; i < Maxn ; i++)
{
Arr[i] = (A * Arr[i-1] + B * Arr[i-2])%7;
if(Arr[i-1] == 1 && Arr[i] == 1)
{
break;
}
}
return (i - 2);
}
}
修改之后的代码实现如下:
标签:imp pac text sample main sse java ati otto
原文地址:https://www.cnblogs.com/674001396long/p/9026504.html