結果
| 問題 |
No.3 ビットすごろく
|
| コンテスト | |
| ユーザー |
Maeda
|
| 提出日時 | 2025-04-11 09:25:28 |
| 言語 | C# (.NET 8.0.404) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,014 bytes |
| コンパイル時間 | 7,705 ms |
| コンパイル使用メモリ | 171,512 KB |
| 実行使用メモリ | 71,104 KB |
| 最終ジャッジ日時 | 2025-04-11 09:25:43 |
| 合計ジャッジ時間 | 14,621 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 TLE * 1 -- * 31 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (98 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
class Program
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
int count = 1;
int i = 1;
while(i != n && i <= 10000)
{
count++;
int move = BitCount(Convert.ToString(i, 2));
if(i < n)
{
i += move;
}
else
{
i -= move;
}
}
if (i == n)
{
Console.WriteLine(count);
}
else
{
Console.WriteLine(-1);
}
}
private static int BitCount(string v)
{
int count = 0;
for (int i = 0; i < v.Length; i++)
{
if (v[i] == '1')
{
count++;
}
}
return count;
}
}
Maeda