<나의풀이>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | class Solution { public String solution(int n, int t, int m, int p) { int num= m*(t-1)+p; int num1=m-p; String answer = ""; String s = snum(n,t,m,p); System.out.println(s); for(int i = p-1; i<num; i+=m){ answer+=s.charAt(i); } return answer; } public String snum(int n, int t, int m, int p){ int num= m*(t-1)+p; String s =""; int i=2; while(true){ String ss =""; for(int j=i; j>0; j/=n){ String ch=""; switch(j%n){ case 10: ch="A"; break; case 11: ch="B"; break; case 12: ch="C"; break; case 13: ch="D"; break; case 14: ch="E"; break; case 15: ch="F"; break; default : ch=Integer.toString(j%n); } ss=ch+ss; } s+=ss; if(s.length()>=num-2) return "01"+s; i++; } } } | cs |