packagecom.semanteme.oj;importjava.util.*;publicclassTest01{publicstaticvoidmain(String[] args){Scanner in =newScanner(System.in);int a = in.nextInt();// 注意 hasNext 和 hasNextLine 的区别try{while(in.hasNextLine()){// 注意 while 处理多个 caseString b = in.nextLine();String ans =getResult(b);System.out.println(ans);if(a--==0){break;}}}catch(Exception e){
in.close();}}privatestaticStringgetResult(String str){if(str ==null&& str.length()==0){return"";}Map<Integer,Integer> pointMap =newHashMap<>();int[] arr =newint[51];
arr[0]=1;
arr[1]=2;
arr[2]=4;
pointMap.put(1,1);
pointMap.put(2,2);
pointMap.put(3,4);StringBuffer stringBuffer =newStringBuffer();for(int i =0; i < str.length(); i++){char c = str.charAt(i);if(isLetter1(c)){int point =0;if(i >2){
point = arr[i -2]+ arr[i -1]+ arr[i -3];
arr[i]= point;}else{
point = arr[i];}int x =(c -'a'+ point)%26+'a';
stringBuffer.append((char) x);}elseif(isLetter2(c)){int point =0;if(i >2){
point = arr[i -2]+ arr[i -1]+ arr[i -3];
arr[i]= point;}else{
point = arr[i];}int x =(c -'A'+ point)%26+'A';
stringBuffer.append((char) x);}else{
stringBuffer.append(c);}}return stringBuffer.toString();}privatestaticbooleanisLetter1(char c){return c >='a'&& c <='z';}privatestaticbooleanisLetter2(char c){return c >='A'&& c <='Z';}}
题2
packagecom.semanteme.oj;importjava.util.*;publicclassTest02{publicstaticvoidmain(String[] args){Scanner in =newScanner(System.in);// 注意 hasNext 和 hasNextLine 的区别while(in.hasNextLine()){// 注意 while 处理多个 caseString b = in.nextLine();// (10,1),(20,1),(30,2),(40,3)// (10,1),(10,1),(30,2),(40,3)String ans =getResult(b);System.out.println(ans);}}privatestaticStringgetResult(String str){List<Integer[]> list =newArrayList<>();String[] split = str.split(",");for(int i =0; i < split.length/2; i++){int a =0;int b =0;if(split[2*i].startsWith("(")){
a =Integer.parseInt(split[2*i].substring(1));}if(split[2*i +1].endsWith(")")){
b =Integer.parseInt(split[2*i +1].substring(0, split[2*i].length()-2));}
list.add(newInteger[]{a, b, i});}Collections.sort(list,(o1, o2)->{return o2[1]- o1[1]!=0? o2[1]- o1[1]: o1[2]- o2[2];});List<Integer[]> list2 =newArrayList<>();Integer[] pre = list.get(0);
list2.add(pre);for(int i =1; i < list.size(); i++){Integer[] cur = list.get(i);if(cur[0]== pre[0]&& cur[1]== pre[1]){continue;}
list2.add(cur);
pre = cur;}StringJoiner stringJoiner =newStringJoiner(",");for(int i =0; i < list2.size(); i++){
stringJoiner.add(list2.get(i)[0]+"");}return stringJoiner.toString();}}