AcWing 1339. 你的旅途由此开始 - Java
原题链接
简单
作者:
KYCygni
,
2021-02-01 01:14:04
,
所有人可见
,
阅读 302
Java code
import java.util.Scanner;
public class Main
{
public static int deCode(String name)
{
int res = 1;
int base = 'A';
int cValue = 0;
for (int i=0; i < name.length(); i++)
{
cValue = (int)name.charAt(i);
res *= (cValue - base + 1 ) % 47;
// or with oneline of code without local variables
// however, this is slightly slower (10 ms per run)
//res *= ((int)name.charAt(i) - 'A' + 1 ) % 47;
}
return res % 47;
}
public static void main (String[] args) throws Exception
{
Scanner cin = new Scanner(System.in);
String aName = cin.nextLine();
String eName = cin.nextLine();
if (deCode(aName) == deCode(eName))
System.out.print("GO");
else
System.out.print("STAY");
}
}