結果

問題 No.581 XOR
ユーザー YOSHIYOSHI
提出日時 2021-03-20 15:04:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 808 bytes
コンパイル時間 4,190 ms
コンパイル使用メモリ 79,988 KB
実行使用メモリ 51,640 KB
最終ジャッジ日時 2024-05-01 01:43:53
合計ジャッジ時間 5,546 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
51,572 KB
testcase_01 AC 92 ms
51,588 KB
testcase_02 AC 101 ms
51,568 KB
testcase_03 AC 91 ms
51,188 KB
testcase_04 AC 93 ms
51,352 KB
testcase_05 AC 93 ms
51,560 KB
testcase_06 AC 92 ms
51,564 KB
testcase_07 AC 93 ms
51,640 KB
testcase_08 AC 95 ms
51,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class No00000581_Main {
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args) throws IOException {
		String[] t = br.readLine().split(" ");
		String a = Long.toBinaryString(Long.parseLong(t[0]));
		String c = Long.toBinaryString(Long.parseLong(t[1]));
		int len = Math.max(a.length(), c.length());
		a = String.format("%" + len + "s", a).replaceAll(" ", "0");
		c = String.format("%" + len + "s", c).replaceAll(" ", "0");
		char[] b = new char[len];
		for(int i = 0; i < a.length(); i++) {
			if(a.charAt(i) == c.charAt(i)) {
				b[i] = '0';
			} else {
				b[i] = '1';
			}
		}
		System.out.println(Long.parseLong(new String(b), 2));
	}
}
0