結果
問題 |
No.887 Collatz
|
ユーザー |
|
提出日時 | 2021-02-04 13:25:25 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 255 bytes |
コンパイル時間 | 1,799 ms |
コンパイル使用メモリ | 191,476 KB |
最終ジャッジ日時 | 2025-01-18 11:14:02 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int n,ans1,ans2; cin >> n; ans1=0; ans2=n; while(n!=1){ if(n%2==0){ n/=2; }else{ n=3*n+1; ans2=max(ans2,n); } ans1++; } cout << ans1 << endl << ans2 << endl; return 0; }