結果

問題 No.887 Collatz
ユーザー bluemeganebluemegane
提出日時 2021-04-18 10:52:00
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 638 bytes
コンパイル時間 748 ms
コンパイル使用メモリ 65,288 KB
実行使用メモリ 22,760 KB
最終ジャッジ日時 2023-09-17 07:32:43
合計ジャッジ時間 4,238 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
18,632 KB
testcase_01 AC 56 ms
22,760 KB
testcase_02 AC 56 ms
22,692 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 54 ms
20,640 KB
testcase_06 AC 55 ms
20,592 KB
testcase_07 AC 54 ms
20,680 KB
testcase_08 AC 55 ms
20,696 KB
testcase_09 AC 54 ms
18,632 KB
testcase_10 AC 54 ms
20,664 KB
testcase_11 AC 54 ms
22,688 KB
testcase_12 AC 55 ms
22,668 KB
testcase_13 AC 54 ms
20,752 KB
testcase_14 AC 55 ms
20,624 KB
testcase_15 AC 56 ms
22,736 KB
testcase_16 AC 54 ms
20,660 KB
testcase_17 AC 55 ms
22,700 KB
testcase_18 AC 54 ms
20,632 KB
testcase_19 AC 55 ms
20,812 KB
testcase_20 AC 54 ms
20,664 KB
testcase_21 AC 55 ms
22,704 KB
testcase_22 AC 54 ms
20,620 KB
testcase_23 AC 55 ms
22,716 KB
testcase_24 AC 54 ms
18,588 KB
testcase_25 AC 55 ms
20,568 KB
testcase_26 AC 54 ms
20,608 KB
testcase_27 AC 56 ms
18,672 KB
testcase_28 AC 55 ms
20,776 KB
testcase_29 AC 55 ms
20,660 KB
testcase_30 AC 55 ms
22,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using static System.Math;
using System;

public class Hello
{
    static void Main()
    {
        var n0 = int.Parse(Console.ReadLine().Trim());
        getAns(n0);
    }
    static void getAns (int n0)
    {
        var p = 0;
        var nmax = n0;
        var i1 = 1000;
        while ( p++ < 400)
        {
            if (n0 % 2 == 0)
            {
                n0 /= 2;
                if (n0 == 1) i1 = Min(i1, p);
            }
            else
            {
                n0 = 3 * n0 + 1;
                nmax = Max(nmax, n0);
            }
        }
        Console.WriteLine(i1);
        Console.WriteLine(nmax);
    }
}
0