結果
| 問題 |
No.887 Collatz
|
| コンテスト | |
| ユーザー |
ks2m
|
| 提出日時 | 2019-09-20 22:26:00 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 134 ms / 2,000 ms |
| コード長 | 395 bytes |
| コンパイル時間 | 2,772 ms |
| コンパイル使用メモリ | 73,916 KB |
| 実行使用メモリ | 54,468 KB |
| 最終ジャッジ日時 | 2024-09-14 18:17:35 |
| 合計ジャッジ時間 | 8,051 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.close();
int i = 0;
int max = n;
while (n > 1) {
if (n % 2 == 0) {
n /= 2;
} else {
n = 3 * n + 1;
}
i++;
max = Math.max(max, n);
}
System.out.println(i);
System.out.println(max);
}
}
ks2m