結果
問題 | No.887 Collatz |
ユーザー |
![]() |
提出日時 | 2019-10-01 13:49:31 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 24 ms / 2,000 ms |
コード長 | 836 bytes |
コンパイル時間 | 677 ms |
コンパイル使用メモリ | 113,256 KB |
実行使用メモリ | 26,896 KB |
最終ジャッジ日時 | 2024-10-03 05:40:57 |
合計ジャッジ時間 | 2,107 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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 == 1) { break; } if (n % 2 == 0) { n = n / 2; } else { n = 3 * n + 1; } list.Add(n); cnt++; } Console.WriteLine(cnt); Console.WriteLine(list.Max()); } } }