結果

問題 No.638 Sum of "not power of 2"
ユーザー bluemeganebluemegane
提出日時 2018-09-09 13:09:50
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 59 ms / 1,000 ms
コード長 659 bytes
コンパイル時間 2,078 ms
コンパイル使用メモリ 103,180 KB
実行使用メモリ 22,840 KB
最終ジャッジ日時 2023-08-24 20:27:55
合計ジャッジ時間 3,722 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
22,732 KB
testcase_01 AC 55 ms
20,804 KB
testcase_02 AC 55 ms
20,876 KB
testcase_03 AC 56 ms
22,616 KB
testcase_04 AC 58 ms
22,752 KB
testcase_05 AC 55 ms
22,772 KB
testcase_06 AC 58 ms
20,808 KB
testcase_07 AC 58 ms
20,804 KB
testcase_08 AC 58 ms
22,656 KB
testcase_09 AC 58 ms
20,812 KB
testcase_10 AC 59 ms
22,840 KB
testcase_11 AC 59 ms
22,840 KB
testcase_12 AC 55 ms
20,712 KB
testcase_13 AC 58 ms
20,856 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

public class Hello
{
    public static void Main()
    {
        var s = new long[60];
        s[0] = 1;
        for (int i = 1; i < 60; i++)
            s[i] = s[i - 1] * 2L;
        var n = long.Parse(Console.ReadLine().Trim());
        for (int i = 3; i < n; i++)
            if (check(s, i) && check(s, n - i)) { Console.WriteLine("{0} {1}", i, n - i); goto end; }
        Console.WriteLine(-1);
        end:;
    }
    public static bool check(long[] s, long n)
    {
        for (int i = 0; i < 60; i++)
        {
            if (n == s[i]) return false;
            else if (n < s[i]) return true;
        }
        return true;
    }
}
0