結果
| 問題 | No.638 Sum of "not power of 2" |
| コンテスト | |
| ユーザー |
bluemegane
|
| 提出日時 | 2018-09-09 13:09:50 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 24 ms / 1,000 ms |
| コード長 | 659 bytes |
| 記録 | |
| コンパイル時間 | 926 ms |
| コンパイル使用メモリ | 103,808 KB |
| 実行使用メモリ | 17,792 KB |
| 最終ジャッジ日時 | 2024-12-23 06:16:46 |
| 合計ジャッジ時間 | 1,952 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 12 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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;
}
}
bluemegane