結果

問題 No.638 Sum of "not power of 2"
ユーザー p_nixp_nix
提出日時 2018-01-26 23:21:27
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 1,191 bytes
コンパイル時間 3,387 ms
コンパイル使用メモリ 104,092 KB
実行使用メモリ 24,944 KB
最終ジャッジ日時 2023-08-28 18:13:01
合計ジャッジ時間 5,922 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
24,944 KB
testcase_01 AC 51 ms
20,700 KB
testcase_02 AC 52 ms
22,684 KB
testcase_03 AC 52 ms
20,784 KB
testcase_04 AC 55 ms
22,748 KB
testcase_05 AC 52 ms
20,816 KB
testcase_06 AC 54 ms
22,724 KB
testcase_07 AC 54 ms
18,624 KB
testcase_08 AC 55 ms
18,768 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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
    {
        static void Main(string[] args)
        {
            long a = long.Parse(Console.ReadLine());
            int ret = -1;
            bool flg = false;
            for (int 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,a-ret);
            }
        }

        static bool ispower2(float v)
        {
            float tmp = 1;
            bool ret = false;

            while (true)
            {
                if (tmp>v)
                {
                    return false;
                }
                if (v == tmp)
                {
                    return true;
                }
                tmp = tmp * 2;
            }
        }
    }
}
0