結果

問題 No.887 Collatz
コンテスト
ユーザー aaa aa
提出日時 2025-12-10 12:45:21
言語 C#
(.NET 10.0.201)
コンパイル:
dotnet_c
実行:
/usr/bin/dotnet_wrap
結果
AC  
実行時間 31 ms / 2,000 ms
+ 247µs
コード長 492 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,951 ms
コンパイル使用メモリ 170,964 KB
実行使用メモリ 193,364 KB
最終ジャッジ日時 2026-07-19 09:01:39
合計ジャッジ時間 8,010 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (91 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net10.0/main.dll
  main -> /home/judge/data/code/bin/Release/net10.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