結果
| 問題 |
No.642 Two Operations No.1
|
| コンテスト | |
| ユーザー |
bluemegane
|
| 提出日時 | 2018-09-09 10:59:49 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 828 bytes |
| コンパイル時間 | 2,590 ms |
| コンパイル使用メモリ | 103,552 KB |
| 実行使用メモリ | 523,508 KB |
| 最終ジャッジ日時 | 2024-12-23 02:45:29 |
| 合計ジャッジ時間 | 29,605 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 TLE * 6 MLE * 3 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System.Collections.Generic;
using System;
public class P
{
public int a { get; set; }
public int times { get; set; }
}
public class Hello
{
public static void Main()
{
var n = int.Parse(Console.ReadLine().Trim());
var ans = getA(n);
Console.WriteLine(ans);
}
public static int getA (int n)
{
var q = new Queue<P>();
q.Enqueue(new P { a = n, times = 0 });
while (true)
{
var w = q.Dequeue();
if (w.a == 1) return w.times;
if (w.a % 2 == 0)
{
q.Enqueue(new P { a = w.a / 2, times = w.times + 1 });
q.Enqueue(new P { a = w.a + 1, times = w.times + 1 });
}
else q.Enqueue(new P { a = w.a + 1, times = w.times + 1 });
}
}
}
bluemegane