結果

問題 No.638 Sum of "not power of 2"
ユーザー p_nixp_nix
提出日時 2018-01-26 23:41:57
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,324 bytes
コンパイル時間 1,973 ms
コンパイル使用メモリ 105,208 KB
実行使用メモリ 23,388 KB
最終ジャッジ日時 2023-08-28 18:14:41
合計ジャッジ時間 3,433 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
21,204 KB
testcase_01 AC 52 ms
21,096 KB
testcase_02 AC 52 ms
21,168 KB
testcase_03 AC 52 ms
23,388 KB
testcase_04 AC 54 ms
21,224 KB
testcase_05 AC 52 ms
21,156 KB
testcase_06 AC 54 ms
19,172 KB
testcase_07 AC 54 ms
21,380 KB
testcase_08 AC 54 ms
21,284 KB
testcase_09 WA -
testcase_10 AC 54 ms
21,264 KB
testcase_11 AC 55 ms
23,244 KB
testcase_12 AC 53 ms
23,132 KB
testcase_13 AC 54 ms
21,124 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace prob638
{
    class Program
    {
        public static ulong[] data = new ulong[80];
        static void Main(string[] args)
        {
            
            for (int i = 0; i < 80; i++)
            {
                data[i] = (ulong)Math.Pow(2, i);
            }
            long a = long.Parse(Console.ReadLine());
            long ret = -1;
            bool flg = false;
            for (long i = 1; i < a/2+1; i++)
            {
                if (!ispower2(i) && !ispower2(a - i))
                {
                    flg = true;
                    ret = i;
                    break;
                }
                else
                {
                    flg = false;
                }
            }
            if (flg==false)
            {
                Console.WriteLine(-1);
            }
            else
            {
                Console.WriteLine("{0} {1}", ret,(long)(a-ret));
            }
        }

        static bool ispower2(float v)
        {
            for (int i = 0; i < 50; i++)
            {
                if (v == data[i])
                {
                    return true;
                }
                if (data[i]>v)
                {
                    return false;
                }
            }
            return false;
        }
    }
}
0