結果

問題 No.1450 nahco314's First Problem
ユーザー bluemeganebluemegane
提出日時 2021-05-20 11:13:07
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 808 bytes
コンパイル時間 890 ms
コンパイル使用メモリ 104,064 KB
実行使用メモリ 17,920 KB
最終ジャッジ日時 2024-04-26 02:09:23
合計ジャッジ時間 6,490 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
17,792 KB
testcase_01 AC 21 ms
17,664 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 21 ms
17,536 KB
testcase_05 AC 22 ms
17,536 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 21 ms
17,792 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 21 ms
17,536 KB
testcase_32 WA -
testcase_33 AC 22 ms
17,792 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using static System.Math;
using System;

public class Hello
{
    static void Main()
    {
        var x = long.Parse(Console.ReadLine().Trim());
        getAns(x);
    }
    static void getAns(long x)
    {
        var imin = Max(0, x - 60);
        var imax = x + 60;
        for (long i = imin; i <= imax; i++)
        {
            if ((i ^ cb(i)) == x) { Console.WriteLine(i); return; }
        }
        Console.WriteLine(-1);
    }
    static int cb(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