結果

問題 No.638 Sum of "not power of 2"
ユーザー バカらっくバカらっく
提出日時 2018-01-27 06:32:22
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 57 ms / 1,000 ms
コード長 1,445 bytes
コンパイル時間 2,013 ms
コンパイル使用メモリ 103,056 KB
実行使用メモリ 22,792 KB
最終ジャッジ日時 2023-08-28 18:18:25
合計ジャッジ時間 3,521 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
20,676 KB
testcase_01 AC 56 ms
20,732 KB
testcase_02 AC 55 ms
22,732 KB
testcase_03 AC 57 ms
22,696 KB
testcase_04 AC 56 ms
20,612 KB
testcase_05 AC 57 ms
22,716 KB
testcase_06 AC 57 ms
20,732 KB
testcase_07 AC 55 ms
18,680 KB
testcase_08 AC 56 ms
20,680 KB
testcase_09 AC 55 ms
20,644 KB
testcase_10 AC 55 ms
20,668 KB
testcase_11 AC 56 ms
22,792 KB
testcase_12 AC 57 ms
20,776 KB
testcase_13 AC 56 ms
22,708 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        long num = long.Parse(Reader.ReadLine());
        Dictionary<long, bool> dic = new Dictionary<long, bool>();
        for (int i = 0; i <= 62; i++) {
            dic.Add(1L<<i, true);
        }

        long max = num / 2;
        for (long i = 1; i <= max;i++ ) {
            if(dic.ContainsKey(i)) {
                continue;
            }
            long tmp = num - i;
            if(dic.ContainsKey(tmp)) {
                continue;
            }
            Console.WriteLine(i + " " + tmp);
            return;
        }
        Console.WriteLine(-1);

    }





    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"


11





";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}
0