結果
| 問題 | No.887 Collatz |
| コンテスト | |
| ユーザー |
GodNegoto
|
| 提出日時 | 2019-11-07 14:14:55 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 134 ms / 2,000 ms |
| コード長 | 456 bytes |
| 記録 | |
| コンパイル時間 | 4,210 ms |
| コンパイル使用メモリ | 74,048 KB |
| 実行使用メモリ | 41,780 KB |
| 最終ジャッジ日時 | 2024-09-15 00:39:42 |
| 合計ジャッジ時間 | 9,348 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
package algo;
import java.util.Scanner;
//import algo.*;
public class sample7 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int cnt = 0;
int max = n;
while (n != 1) {
if(n % 2 == 0) {
n = n / 2;
}
else {
n = 3 * n + 1;
}
cnt++;
max = Math.max(max, n);
}
System.out.println(cnt);
System.out.println(max);
}
}
GodNegoto