import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
public class Main {
public static void main(String[] args) throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
StringBuilder sb = new StringBuilder("");
int[] x=new int[27];
for(int i=1;i<27;i++){
x[i]=i;
}
String m="";
while(true){
String ansS="";
String ansN="";
m=br.readLine();
if("*".equals(m))
break;
if(m.charAt(0)>='0' && m.charAt(0)<='9'){
ansS=bigInttoString(new BigInteger(m));
ansN=m;
}else{
ansS=m;
ansN=stringtoBigInt(m, x).toString();
}
ansN=addComas(ansN);
sb.append(ansS);
for(int i=ansS.length();i<22;i++){
sb.append(" ");
}
sb.append(ansN).append("\n");
}
System.out.print(sb);
}
static BigInteger stringtoBigInt(String x,int []arr){
BigInteger temp= BigInteger.ZERO;
for(int i=0;i<x.length();i++){
int index=x.charAt(i)-96;
if(index>0 && index<27)
temp=temp.add(BigInteger.valueOf(index).multiply(BigInteger.valueOf(26).pow(x.length()-i-1)));
}
return temp;
}
static String bigInttoString(BigInteger x){
StringBuilder sb= new StringBuilder("");
BigInteger bg=x;
while (bg.compareTo(BigInteger.ZERO)>0){
BigInteger lol=bg.mod(BigInteger.valueOf(26));
int sim=lol.intValue();
bg=bg.divide(BigInteger.valueOf(26));
char c=(char) (lol.intValue()+96);
sb.append(c);
}
return sb.reverse().toString();
}
static String addComas(String x){
StringBuilder sb=new StringBuilder("");
for(int i=x.length()-1,index=1;i>0;i--,index++){
sb.append(x.charAt(i));
if(index%3==0)
sb.append(",");
}
sb.append(x.charAt(0));
return sb.reverse().toString();
}
}
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
public class Main {
public static void main(String[] args) throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
StringBuilder sb = new StringBuilder("");
int[] x=new int[27];
for(int i=1;i<27;i++){
x[i]=i;
}
String m="";
while(true){
String ansS="";
String ansN="";
m=br.readLine();
if("*".equals(m))
break;
if(m.charAt(0)>='0' && m.charAt(0)<='9'){
ansS=bigInttoString(new BigInteger(m));
ansN=m;
}else{
ansS=m;
ansN=stringtoBigInt(m, x).toString();
}
ansN=addComas(ansN);
sb.append(ansS);
for(int i=ansS.length();i<22;i++){
sb.append(" ");
}
sb.append(ansN).append("\n");
}
System.out.print(sb);
}
static BigInteger stringtoBigInt(String x,int []arr){
BigInteger temp= BigInteger.ZERO;
for(int i=0;i<x.length();i++){
int index=x.charAt(i)-96;
if(index>0 && index<27)
temp=temp.add(BigInteger.valueOf(index).multiply(BigInteger.valueOf(26).pow(x.length()-i-1)));
}
return temp;
}
static String bigInttoString(BigInteger x){
StringBuilder sb= new StringBuilder("");
BigInteger bg=x;
while (bg.compareTo(BigInteger.ZERO)>0){
BigInteger lol=bg.mod(BigInteger.valueOf(26));
int sim=lol.intValue();
bg=bg.divide(BigInteger.valueOf(26));
char c=(char) (lol.intValue()+96);
sb.append(c);
}
return sb.reverse().toString();
}
static String addComas(String x){
StringBuilder sb=new StringBuilder("");
for(int i=x.length()-1,index=1;i>0;i--,index++){
sb.append(x.charAt(i));
if(index%3==0)
sb.append(",");
}
sb.append(x.charAt(0));
return sb.reverse().toString();
}
}
No comments:
Post a Comment