結果

問題 No.939 and or
ユーザー bluemeganebluemegane
提出日時 2021-04-26 15:04:50
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 883 bytes
コンパイル時間 954 ms
コンパイル使用メモリ 63,472 KB
実行使用メモリ 25,208 KB
最終ジャッジ日時 2023-09-18 07:57:20
合計ジャッジ時間 4,002 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
22,772 KB
testcase_01 AC 56 ms
20,704 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 55 ms
20,648 KB
testcase_06 WA -
testcase_07 AC 61 ms
25,208 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 61 ms
23,048 KB
testcase_12 WA -
testcase_13 AC 55 ms
18,600 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 61 ms
23,164 KB
testcase_19 WA -
testcase_20 AC 56 ms
20,632 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 60 ms
23,024 KB
testcase_24 AC 60 ms
23,096 KB
testcase_25 AC 61 ms
23,000 KB
testcase_26 AC 61 ms
25,116 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 57 ms
20,540 KB
testcase_30 WA -
testcase_31 AC 56 ms
22,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using static System.Math;
using System;

public class Hello
{
    public static long a, b;
    static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        a = long.Parse(line[0]);
        b = long.Parse(line[1]);
        getAns();
    }
    static bool check(long t, int p) => ((t >> p) & 1) == 1;
    static void getAns()
    {
        var x = 1L;
        var imax = 0;
        var abmax = Max(a, b);
        for (int i = 0; i < 31; i++)
        {
            if (x >= abmax) { imax = i; break; }
            x *= 2;
        }
        var count = 0;
        for (int i = 0; i < imax; i++)
        {
            if (check(a, i) && !check(b, i)) { Console.WriteLine(0); return; }
            if (!check(a, i) && check(b, i)) count++;
        }
        if (count <= 1) Console.WriteLine(1);
        else Console.WriteLine(Pow(2, count - 1));
    }
}
0