1720、1062、2104、1064、2734、1170、1197、2629
import java.util.Scanner;
import java.text.DecimalFormat;
public class Day3 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// 1720.A+B Coming
// JAVA可以直接读取16进制的数,默认输出都是十进制
// while (sc.hasNext()) {
// int n = sc.nextInt(16), m = sc.nextInt(16);
// System.out.println(m+n);
// }
// 1062.Text Reverse
// while(sc.hasNext()){
// int n = sc.nextInt();
// sc.nextLine(); //接收回车符
// for(int i = 0; i < n; i++){
每一行存入str
// String s = sc.nextLine();
// String []str = s.split(" "); // String[] 表示这是一个字符串类型的数组
// String output = "";
// for (int j=0;j<str.length;j++){
对每个元素逆序S
// for(int k=str[j].length()-1;k>=0;k--){
// output += str[j].charAt(k);
// }
// output += " ";
// }
// System.out.println(output);
// }
// }
// 2104.hide handkerchief
// 刚好除尽就找不到,转一圈回到原点,有些点永远到不了
// 找最大公约数
// while(sc.hasNext()){
// int n = sc.nextInt(), m = sc.nextInt();
// if(n==-1 && m==-1)break;
// int tmp;
// while(m!=0){
// tmp = n%m; //刚好除尽,tmp=0
// n = m; //如果没有其他公约数的话,最后一步一定是个 x%1=0 -> n=1\m=0
// m = tmp; //结束循环
// }
// if (n == 1){
// System.out.println("YES");
// }
// else{
// System.out.println("POOR Haha");
// }
// }
// 1064.Financial Management
// while (sc.hasNext()) {
// double sum =0.0;
// for (int i=0;i<12;i++){
// double n = sc.nextDouble();
// sum += n;
// }
// DecimalFormat decimal = new DecimalFormat(".00");
// System.out.println("$"+decimal.format(sum/12));
// }
// 2734.Quicksum
// 在ACSII码中A对应数为65,B对应66,空格32
// s.charAt(i)可以直接获取字符的ASCII码
// while (sc.hasNext()){
// String s = sc.nextLine();
// int sum =0;
// if(s.equals("#"))break;
// for(int i=0;i<s.length();i++){
// if (s.charAt(i) != 32){
// sum += (i+1)* (s.charAt(i) -64);
// }
// }
// System.out.println(sum);
// }
// 1170.Balloon Comes!
// 运算符不能直接获取,只能通过比较来匹配
// 不知道为什么JAVA一直报错
// while (sc.hasNext()){
// int n = sc.nextInt();
// sc.nextLine();
// if(n>0 && n<1000){
// for (int i = 0; i < n; i++) {
// String operator = sc.next();
// int a = sc.nextInt(), b = sc.nextInt();
// sc.nextLine();
// switch (operator){
// case "+":
// System.out.println(a + b);
// break;
// case "-":
// System.out.println(a - b);
// break;
// case "*":
// System.out.println(a * b);
// break;
// case "/":
// double res = (double)a / (double)b;
// int resi = a/b;
// if((double)resi==res){
// System.out.println(resi);
// }
// else {
// DecimalFormat df = new DecimalFormat("0.00");
// System.out.println(df.format(res));
// }
// }
// sc.nextLine();
// }
// }
// }
// 1197.Specialized Four-Digit Numbers
// 手动转换进制
// int sum10, sum12, sum16, a,b;
// for(int n =2992; n<10000;n++){
// sum12=sum16=0;
// sum10 = n/1000+(n%1000)/100+(n%100)/10+n%10;
// a =b =n;
// while(a!=0) {
// sum12 += a % 12;
// a /= 12;
// }
// while(b!=0) {
// sum16 += b % 16;
// b /= 16;
// }
// if (sum10==sum12 && sum10==sum16){
// System.out.println(n);
// }
// }
// 2629.Identity Card
while (sc.hasNext()){
int n = sc.nextInt();
sc.nextLine();
String place = " ";
for (int i = 0; i < n; i++) {
String s = sc.next();
String p = s.substring(0,2);
switch (p){
case "33":
place = "Zhejiang";
break;
case "11":
place="Beijing";
break;
case "71":
place = "Taiwan";
break;
case "81":
place="Hong Kong";
break;
case "82":
place = "Macao";
break;
case "54":
place="Tibet";
break;
case "21":
place="Liaoning";
break;
case "31":
place="Shanghai";
break;
}
System.out.println("He/She is from " + place + ",and his/her birthday is on " + s.substring(10, 12) + "," + s.substring(12, 14) + "," + s.substring(6, 10) + " based on the table.");
}
}
}
}