結果

問題 No.887 Collatz
コンテスト
ユーザー aaa aa
提出日時 2025-12-10 12:45:21
言語 C#
(.NET 8.0.404)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 492 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 7,712 ms
コンパイル使用メモリ 169,432 KB
実行使用メモリ 187,240 KB
最終ジャッジ日時 2025-12-10 12:45:32
合計ジャッジ時間 10,813 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (110 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #
raw source code

using System;

class Program
{
    static void Main()
    {
        long n = long.Parse(Console.ReadLine());
        long current = n;
        long nmax = n;
        int i = 0;

        while (current != 1)
        {
            if ((current & 1) == 0)
                current >>= 1;
            else
                current = current * 3 + 1;

            i++;
            if (current > nmax) nmax = current;
        }

        Console.WriteLine(i);
        Console.WriteLine(nmax);
    }
}
0