import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer("");
while (true) {
int x = Integer.parseInt(br.readLine());
if (x == 0) {
break;
}
String intial = Integer.toBinaryString(x);
StringBuilder str1 = new StringBuilder(""), str2 = new StringBuilder("");
boolean flag = true;
int counter = 0;
for (int i = 0; i < intial.length(); i++) {
if (flag) {
str1.append(intial.charAt(i));
str2.append('0');
} else {
str2.append(intial.charAt(i));
str1.append('0');
}
if (intial.charAt(i) == '1') {
if (flag) {
flag = false;
} else {
flag = true;
}
counter++;
}
}
if (counter % 2 == 0) {
sb.append(Integer.parseInt(str2.toString(), 2)).append(' ').append(Integer.parseInt(str1.toString(), 2)).append('\n');
} else {
sb.append(Integer.parseInt(str1.toString(), 2)).append(' ').append(Integer.parseInt(str2.toString(), 2)).append('\n');
}
}
System.out.print(sb);
}
}
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer("");
while (true) {
int x = Integer.parseInt(br.readLine());
if (x == 0) {
break;
}
String intial = Integer.toBinaryString(x);
StringBuilder str1 = new StringBuilder(""), str2 = new StringBuilder("");
boolean flag = true;
int counter = 0;
for (int i = 0; i < intial.length(); i++) {
if (flag) {
str1.append(intial.charAt(i));
str2.append('0');
} else {
str2.append(intial.charAt(i));
str1.append('0');
}
if (intial.charAt(i) == '1') {
if (flag) {
flag = false;
} else {
flag = true;
}
counter++;
}
}
if (counter % 2 == 0) {
sb.append(Integer.parseInt(str2.toString(), 2)).append(' ').append(Integer.parseInt(str1.toString(), 2)).append('\n');
} else {
sb.append(Integer.parseInt(str1.toString(), 2)).append(' ').append(Integer.parseInt(str2.toString(), 2)).append('\n');
}
}
System.out.print(sb);
}
}
No comments:
Post a Comment