結果
| 問題 | No.887 Collatz |
| コンテスト | |
| ユーザー |
keymoon
|
| 提出日時 | 2020-02-05 14:11:35 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 24 ms / 2,000 ms |
| コード長 | 798 bytes |
| 記録 | |
| コンパイル時間 | 974 ms |
| コンパイル使用メモリ | 112,552 KB |
| 実行使用メモリ | 25,816 KB |
| 最終ジャッジ日時 | 2024-09-22 12:13:21 |
| 合計ジャッジ時間 | 2,649 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;
using System.Threading.Tasks;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
public static class P
{
public static void Main()
{
var n = long.Parse(Console.ReadLine());
int i = 0;
var max = n;
for (; n != 1; i++)
{
if (n % 2 == 0) n /= 2;
else { n *= 3; n++; }
max = Max(max, n);
}
Console.WriteLine(i);
Console.WriteLine(max);
}
}
keymoon