結果

問題 No.939 and or
ユーザー bluemeganebluemegane
提出日時 2021-04-26 14:31:15
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,046 bytes
コンパイル時間 1,421 ms
コンパイル使用メモリ 61,616 KB
実行使用メモリ 27,116 KB
最終ジャッジ日時 2023-09-18 07:15:28
合計ジャッジ時間 5,016 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
22,804 KB
testcase_01 AC 55 ms
22,744 KB
testcase_02 WA -
testcase_03 AC 55 ms
20,804 KB
testcase_04 AC 59 ms
23,128 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 56 ms
22,784 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 57 ms
20,788 KB
testcase_17 AC 59 ms
23,136 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 55 ms
20,724 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 55 ms
20,824 KB
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

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 imax = countBIT(Max(a, b));
        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++;
        }
        Console.WriteLine(Pow(2, count - 1));
    }
    static int countBIT(long bits)
    {
        bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
        bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
        bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
        bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
        return (int)(bits & 0x0000ffff) + (int)(bits >> 16 & 0x0000ffff);
    }
}
0