結果
| 問題 | No.638 Sum of "not power of 2" |
| コンテスト | |
| ユーザー |
bluemegane
|
| 提出日時 | 2018-09-09 13:07:39 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 680 bytes |
| 記録 | |
| コンパイル時間 | 2,630 ms |
| コンパイル使用メモリ | 104,064 KB |
| 実行使用メモリ | 17,920 KB |
| 最終ジャッジ日時 | 2024-12-23 06:12:35 |
| 合計ジャッジ時間 | 1,707 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 |
| other | AC * 10 WA * 2 |
コンパイルメッセージ
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());
var a = 1L;
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