結果

問題 No.887 Collatz
ユーザー mossari_aozoramossari_aozora
提出日時 2019-10-01 13:47:38
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 836 bytes
コンパイル時間 1,054 ms
コンパイル使用メモリ 108,788 KB
実行使用メモリ 26,660 KB
最終ジャッジ日時 2024-04-14 08:33:00
合計ジャッジ時間 2,680 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
24,340 KB
testcase_01 AC 25 ms
24,108 KB
testcase_02 AC 25 ms
24,360 KB
testcase_03 WA -
testcase_04 AC 24 ms
24,216 KB
testcase_05 AC 25 ms
24,852 KB
testcase_06 AC 26 ms
24,624 KB
testcase_07 AC 26 ms
24,596 KB
testcase_08 AC 26 ms
24,592 KB
testcase_09 AC 25 ms
24,368 KB
testcase_10 AC 25 ms
22,432 KB
testcase_11 AC 26 ms
26,540 KB
testcase_12 AC 26 ms
24,364 KB
testcase_13 AC 25 ms
24,600 KB
testcase_14 AC 25 ms
24,720 KB
testcase_15 AC 25 ms
24,492 KB
testcase_16 AC 24 ms
24,624 KB
testcase_17 AC 25 ms
24,724 KB
testcase_18 AC 26 ms
24,468 KB
testcase_19 AC 26 ms
24,728 KB
testcase_20 AC 25 ms
24,596 KB
testcase_21 AC 25 ms
24,464 KB
testcase_22 AC 25 ms
24,236 KB
testcase_23 AC 25 ms
26,280 KB
testcase_24 AC 25 ms
26,400 KB
testcase_25 AC 24 ms
22,324 KB
testcase_26 AC 24 ms
24,364 KB
testcase_27 AC 25 ms
26,400 KB
testcase_28 AC 26 ms
26,660 KB
testcase_29 AC 24 ms
24,596 KB
testcase_30 AC 25 ms
24,596 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Numerics;
using System.Collections.Generic;
using System.Linq;

namespace Program
{
    class Program
    {
        static void Main(string[] args)
        {
            var list = new List<int>();
            var n0 = int.Parse(Console.ReadLine());

            list.Add(n0);
            int n = n0;
            int cnt = 0;
            while (true)
            {
                if (n % 2 == 0)
                {
                    n = n / 2;
                }
                else
                {
                    n = 3 * n + 1;
                }
                list.Add(n);
                cnt++;
                if (n == 1)
                {
                    break;
                }
            }
            Console.WriteLine(cnt);
            Console.WriteLine(list.Max());
        }
    }
}
0