結果
問題 |
No.638 Sum of "not power of 2"
|
ユーザー |
|
提出日時 | 2018-01-26 23:17:03 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,189 bytes |
コンパイル時間 | 1,030 ms |
コンパイル使用メモリ | 104,064 KB |
実行使用メモリ | 22,656 KB |
最終ジャッジ日時 | 2024-12-30 02:27:04 |
合計ジャッジ時間 | 4,050 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 11 TLE * 1 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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-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; } } } }