0 点赞 评论 收藏
分享
Gufra_bollom:import java.util.HashMap; import java.util.Map; import java.util.Scanner; import java.util.Stack; public class Main { private static Map<Integer,Character> map = new HashMap<>(); public static void main(String[] args) { Scanner in = new Scanner(System.in); long key = in.nextLong(); createMap(); String str = func(Math.abs(key)); if (key < 0) str = "-"+str; else if (key == 0) str = "0"; System.out.println(str); } public static void createMap(){ for (int i=0;i<10;i++){ map.put(i,(i+"").charAt(0)); } map.put(10,'`'); map.put(11,'!'); map.put(12,'@'); map.put(13,'#'); map.put(14,'$'); map.put(15,'%'); map.put(16,'^'); map.put(17,'&'); map.put(18,'*'); map.put(19,'('); map.put(20,')'); map.put(21,'{'); map.put(22,'}'); map.put(23,'\\'); map.put(24,'<'); map.put(25,'>'); map.put(26,'?'); } public static String func(long k){ Stack<Long> stack = new Stack<>(); long r = 0; while (k > 0){ r = k % 27; k /= 27; stack.push(r); } StringBuilder stringBuilder = new StringBuilder(); while (!stack.empty()){ long key = stack.pop(); stringBuilder.append(map.get((int)key)); } return stringBuilder.toString(); } }
0 点赞 评论 收藏
分享
2019-08-29 10:56
门头沟学院 C++ 0 点赞 评论 收藏
分享
关注他的用户也关注了: