結果

問題 No.638 Sum of "not power of 2"
ユーザー mbanmban
提出日時 2018-01-31 07:38:23
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 61 ms / 1,000 ms
コード長 1,351 bytes
コンパイル時間 3,978 ms
コンパイル使用メモリ 103,232 KB
実行使用メモリ 22,812 KB
最終ジャッジ日時 2023-08-28 18:22:34
合計ジャッジ時間 5,533 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
22,720 KB
testcase_01 AC 57 ms
20,752 KB
testcase_02 AC 58 ms
20,668 KB
testcase_03 AC 57 ms
18,856 KB
testcase_04 AC 60 ms
20,752 KB
testcase_05 AC 60 ms
22,812 KB
testcase_06 AC 61 ms
22,760 KB
testcase_07 AC 61 ms
20,800 KB
testcase_08 AC 59 ms
20,704 KB
testcase_09 AC 60 ms
22,812 KB
testcase_10 AC 60 ms
20,824 KB
testcase_11 AC 61 ms
20,848 KB
testcase_12 AC 59 ms
20,660 KB
testcase_13 AC 61 ms
20,820 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.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;
using System.Diagnostics;

class Scanner
{
    private readonly char Separator = ' ';
    private int Index = 0;
    private string[] Line = new string[0];
    public string Next()
    {
        if (Index >= Line.Length)
        {
            Line = Console.ReadLine().Split(Separator);
            Index = 0;
        }
        var ret = Line[Index];
        Index++;
        return ret;
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }
}

class Program
{
    private long N;
    private void Scan()
    {
        var sc = new Scanner();
        N = sc.NextLong();
    }

    public void Solve()
    {
        Scan();
        for (long a = 1; a < N; a++)
        {
            long b = N - a;
            if (!(TwoPow(a) || TwoPow(b)))
            {
                Console.WriteLine("{0} {1}", a, b);
                return;
            }
        }
        Console.WriteLine(-1);
    }

    private bool TwoPow(long n)
    {
        return (n & (n - 1)) == 0;
    }

    static public void Main()
    {
        new Program().Solve();
    }
}
0