結果

問題 No.939 and or
ユーザー 37zigen37zigen
提出日時 2019-12-02 18:55:51
言語 Java19
(openjdk 21)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 785 bytes
コンパイル時間 2,576 ms
コンパイル使用メモリ 72,192 KB
実行使用メモリ 56,040 KB
最終ジャッジ日時 2023-08-16 05:24:47
合計ジャッジ時間 8,428 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,900 KB
testcase_01 AC 123 ms
55,628 KB
testcase_02 AC 123 ms
55,580 KB
testcase_03 AC 123 ms
55,800 KB
testcase_04 AC 124 ms
55,992 KB
testcase_05 AC 126 ms
55,848 KB
testcase_06 AC 125 ms
55,700 KB
testcase_07 AC 127 ms
55,696 KB
testcase_08 AC 125 ms
55,824 KB
testcase_09 AC 125 ms
56,012 KB
testcase_10 AC 124 ms
55,656 KB
testcase_11 AC 124 ms
56,040 KB
testcase_12 AC 126 ms
55,776 KB
testcase_13 AC 130 ms
55,784 KB
testcase_14 AC 127 ms
55,876 KB
testcase_15 AC 124 ms
55,548 KB
testcase_16 AC 126 ms
55,940 KB
testcase_17 AC 124 ms
55,556 KB
testcase_18 AC 130 ms
55,848 KB
testcase_19 AC 124 ms
55,808 KB
testcase_20 AC 123 ms
55,480 KB
testcase_21 AC 123 ms
55,728 KB
testcase_22 AC 122 ms
55,908 KB
testcase_23 AC 123 ms
55,792 KB
testcase_24 AC 123 ms
55,656 KB
testcase_25 AC 123 ms
55,840 KB
testcase_26 AC 126 ms
54,396 KB
testcase_27 AC 128 ms
55,892 KB
testcase_28 AC 126 ms
55,892 KB
testcase_29 AC 121 ms
55,784 KB
testcase_30 AC 125 ms
55,860 KB
testcase_31 AC 126 ms
55,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
    
    void run() {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long ans=1;
        //and,or
        //10 x
        //01 10,01
        //11 11
        //00 00
        for (long i=0;i<31;++i){
            long u=(A>>i)%2;
            long v=(B>>i)%2;
            if(u==1&&v==0)ans=0;
            else if(u==0&&v==1)ans=ans*2;
            else if(u==1&&v==1)ans=ans;
            else if(u==0&&v==0)ans=ans;
        }
        if(ans==1)System.out.println(ans);
        else System.out.println(ans/2);
    }

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}
0