結果
問題 | No.642 Two Operations No.1 |
ユーザー | bluemegane |
提出日時 | 2018-09-09 10:59:49 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 828 bytes |
コンパイル時間 | 2,558 ms |
コンパイル使用メモリ | 103,080 KB |
実行使用メモリ | 598,604 KB |
最終ジャッジ日時 | 2023-08-24 18:14:00 |
合計ジャッジ時間 | 7,230 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | MLE | - |
testcase_01 | AC | 57 ms
20,668 KB |
testcase_02 | AC | 57 ms
20,636 KB |
testcase_03 | AC | 55 ms
20,636 KB |
testcase_04 | MLE | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
コンパイルメッセージ
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 }); } } }