結果
| 問題 |
No.638 Sum of "not power of 2"
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-01-26 23:41:00 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,322 bytes |
| コンパイル時間 | 1,120 ms |
| コンパイル使用メモリ | 111,596 KB |
| 実行使用メモリ | 26,200 KB |
| 最終ジャッジ日時 | 2024-12-30 02:33:28 |
| 合計ジャッジ時間 | 2,242 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / 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;
namespace prob638
{
class Program
{
public static ulong[] data = new ulong[70];
static void Main(string[] args)
{
for (int i = 0; i < 70; i++)
{
data[i] = (ulong)Math.Pow(2, i);
}
long a = long.Parse(Console.ReadLine());
long ret = -1;
bool flg = false;
for (long i = 1; i < a/2; 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,(long)(a-ret));
}
}
static bool ispower2(float v)
{
for (int i = 0; i < 50; i++)
{
if (v == data[i])
{
return true;
}
if (data[i]>v)
{
return false;
}
}
return false;
}
}
}