import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args){
int t,count=0,p,div,mt;
int N;int k,m=0,b,lsa=0,lsb=0,lsm=0;
Scanner j=new Scanner(System.in);
t=j.nextInt();
int i,ed=0;
for(i=1;i<=t;i++)
{
N=j.nextInt();
System.out.printf("Case #%d: ",i);
k=N;mt=N;
while(mt!=0)
{b=mt%10;
m=m*10+b; if(b==4) { lsa++;}
mt=mt/10;
}b=0;m=0;
if(lsa==0){System.out.printf("NO SOLUTION");}
else {
if(N%2==0){ div=N/2;
while(div!=0)
{
b=div%10;
m=m*10+b;
div=div/10;
if(b==4) { lsb++;}
}b=0;m=0;}
else { lsb++;}
if(lsb==0){System.out.printf("%d %d\n",N/2,N/2);}
else {
while(k!=0)
{
b=k%10;
m=m*10+b;
k=k/10;
}b=0;p=m;m=0;
while(p!=0)
{
b=p%10;
if(b==4){ b=1;}else {b=0;}
m=m*10+b;
p=p/10;
}b=0;int A=N-m;int B=m;
System.out.printf("%d %d\n",A,B);
m=0;lsb=0;lsa=0;
}
}
}
}
}
--
You received this message because you are subscribed to the Google Groups
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-code/df40d351-1884-4870-9ef7-fa3d83d57e2f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.