結果
| 問題 |
No.887 Collatz
|
| コンテスト | |
| ユーザー |
mossari_aozora
|
| 提出日時 | 2019-10-01 13:47:38 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 836 bytes |
| コンパイル時間 | 671 ms |
| コンパイル使用メモリ | 112,704 KB |
| 実行使用メモリ | 26,544 KB |
| 最終ジャッジ日時 | 2024-10-03 05:40:54 |
| 合計ジャッジ時間 | 2,128 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 WA * 1 |
コンパイルメッセージ
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 % 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());
}
}
}
mossari_aozora