結果
| 問題 |
No.3 ビットすごろく
|
| コンテスト | |
| ユーザー |
ub_nyaoiix
|
| 提出日時 | 2016-12-18 10:46:17 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 578 bytes |
| コンパイル時間 | 3,100 ms |
| コンパイル使用メモリ | 102,784 KB |
| 実行使用メモリ | 34,048 KB |
| 最終ジャッジ日時 | 2024-12-14 08:02:46 |
| 合計ジャッジ時間 | 110,554 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 9 WA * 6 TLE * 18 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
class Q0003
{
public static void Main()
{
int n = int.Parse(Console.ReadLine());
int bit=0;
for (int i=n; i>0; i/=2)
{
if (i%2 > 0)
{
bit ++;
}
}
if (n>2 && bit==1)
{
Console.WriteLine(-1);
return;
}
int count = 1;
int prev = -1;
for(int i=1; ;)
{
if (i == n)
{
break;
}
int add = 0;
for (int j=i; j>0; j/=2)
{
if(j%2 > 0)
{
add ++;
}
}
if(i+add > n)
{
i -= add;
}
else
{
i += add;
}
prev = i;
count++;
}
Console.WriteLine(count);
}
}
ub_nyaoiix