⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 namepk.java

📁 第四届百度杯编程大赛final解题报告+标程
💻 JAVA
字号:
import java.util.*;

public class NamePK {
	
	static Scanner in = new Scanner(System.in);
	
	public static void main(String args[]) throws Exception {
		int testNum = in.nextInt();
		while (testNum > 0) {
			testNum --;
			String s = in.next();
			String t = in.next();
			int hp1 = 0, hp2 = 0, str1 = 1, str2 = 1, spd1 = 0, spd2 = 0;
			for (int i = 0; i < s.length(); i ++) {
				hp1 = (hp1 + (83 - (int) s.charAt(i)) * (83 - (int) s.charAt(i))) % 97;
				str1 = (str1 * (int) s.charAt(i)) % 79;
				for (int j = i + 1; j < s.length(); j ++) {
					spd1 = (spd1 + (int) s.charAt(i) * (int) s.charAt(j)) % 11;
				}
			}
			for (int i = 0; i < t.length(); i ++) {
				hp2 = (hp2 + (83 - (int) t.charAt(i)) * (83 - (int) t.charAt(i))) % 97;
				str2 = (str2 * (int) t.charAt(i)) % 79;
				for (int j = i + 1; j < t.length(); j ++) {
					spd2 = (spd2 + (int) t.charAt(i) * (int) t.charAt(j)) % 11;
				}
			}
			hp1 = 300 - hp1;
			hp2 = 300 - hp2;
			str1 += 22;
			str2 += 22;
			int t1 = hp2 / str1;
			if (hp2 % str1 != 0)
				t1 ++;
			int t2 = hp1 / str2;
			if (hp1 % str2 != 0)
				t2 ++;
			t1 *= (20 - spd1);
			t2 *= (20 - spd2);
			if (t1 == t2)
				System.out.println("tie");
			else
				if (t1 < t2)
					System.out.println("win");
				else
					System.out.println("lose");
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -