結果
| 問題 |
No.887 Collatz
|
| コンテスト | |
| ユーザー |
watarimaycry2
|
| 提出日時 | 2019-09-20 22:24:32 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 159 ms / 2,000 ms |
| コード長 | 521 bytes |
| コンパイル時間 | 2,560 ms |
| コンパイル使用メモリ | 76,524 KB |
| 実行使用メモリ | 42,528 KB |
| 最終ジャッジ日時 | 2024-09-14 18:14:46 |
| 合計ジャッジ時間 | 8,413 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
import java.util.*;
public class Main {
public static void myout(Object text){//standard output
System.out.println(text);
}
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
//String tmp = sc.next();
//int tmp = sc.nextInt();
//Long tmp = sc.nextLong();
Long n = sc.nextLong();
Long m = n;
int i = 0;
while(n != 1){
if(n % 2 == 0){
n = n / 2;
}else{
n = 3 * n + 1;
}
i++;
m = Math.max(m,n);
}
myout(i + "\n" + m);
}
}
watarimaycry2