杭电acm1005题为什么AC不了
importjava.util.*;publicclassMain{publicstaticvoidmain(String[]args){intn,A,B,a[];Sca...
import java.util.*;
public class Main {
public static void main(String []args){
int n,A,B,a[];
Scanner scan=new Scanner(System.in);
while((A=scan.nextInt())+(B=scan.nextInt())+(n=scan.nextInt())!=0){
if(1<=A&&A<=1000&&1<=B&&B<=1000&&1<=n&&n<=100000000){
a=new int[n+1];
a[1]=1;
a[2]=1;
for(int i=3;i<=n;i++){
a[i]=(A*a[i-1]+B*a[i-2])%7;
}
System.out.println(a[n]);
}
}
}
} 展开
public class Main {
public static void main(String []args){
int n,A,B,a[];
Scanner scan=new Scanner(System.in);
while((A=scan.nextInt())+(B=scan.nextInt())+(n=scan.nextInt())!=0){
if(1<=A&&A<=1000&&1<=B&&B<=1000&&1<=n&&n<=100000000){
a=new int[n+1];
a[1]=1;
a[2]=1;
for(int i=3;i<=n;i++){
a[i]=(A*a[i-1]+B*a[i-2])%7;
}
System.out.println(a[n]);
}
}
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询