Guest User

Foregone CodeJam

a guest
Apr 1st, 2020
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.00 KB | None | 0 0
  1. import java.util.*;
  2. import java.io.*;
  3. class CodeJam{ 
  4.    
  5.     public static void main(String[] args){
  6.        
  7.         //Scanner in = new Scanner(System.in);
  8.         Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
  9.         int caseq = 1;
  10.         int t = in.nextInt();
  11.         while(t-->0){
  12.            
  13.             String x = in.next();
  14.            
  15.             String a="";
  16.             String b="";
  17.            
  18.             int n = x.length();
  19.             for(int i=n-1;i>=0;i--){
  20.                 if(x.charAt(i) == '4'){
  21.                     a="2"+a;
  22.                     b="2"+b;
  23.                 }else{
  24.                     a=x.charAt(i)+a;
  25.                     b="0"+b;
  26.                 }
  27.             }
  28.            
  29.             int start=0;
  30.             while(b.charAt(start)=='0'){
  31.                 start++;
  32.             }
  33.             System.out.println("Case #"+caseq+":"+a+" "+b.substring(start));
  34.             caseq++;
  35.            
  36.         }  
  37.     }
  38.    
  39. }
Add Comment
Please, Sign In to add comment