洛谷P1200 问题:麻烦大家帮我看看哪里出错了,为什么无论输入什么,结果都是STAY
import java.util.Scanner;
public class P1200_UFO {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String a = sc.nextLine();//彗星
String b = sc.nextLine();//小组
char []c = a.toCharArray();
char []d = b.toCharArray();
char []e = new char[] {'A','B','C','D','E','F','G', 'H','I','J','K','L','M','N','O','P','Q','R','S','T','U', 'V','W','X','Y','Z'};
int f = 1,g =1;
for(char ch:c)
{
int index = 25;//将数组最后一个元素的索引存储在index中
//不能从第一个元素开始,因为数组第一个元素的索引为0
for(char gc:d)
{
if(ch==gc) {
f *=(index+1);
break;
}
index--;
}
}
for(char ch:d)
{
int index = 25;
for(char cc:c)
{
if(ch==cc) {
g *= (index+1);
break;
}
index--;
}
}
if(g%47==f%47)
{
System.out.println("GO");
}else {
System.out.println("STAY");
}
sc.close();
}
}