結果
問題 |
No.887 Collatz
|
ユーザー |
|
提出日時 | 2022-05-18 21:12:41 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 330 bytes |
コンパイル時間 | 1,312 ms |
コンパイル使用メモリ | 166,812 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-17 00:46:49 |
合計ジャッジ時間 | 2,351 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
#include<bits/stdc++.h> using namespace std; int main(){ long long int n; cin >> n; long long int now = n,ans1=0,ans2=n; for(;;){ if(now == 1) break; if(now%2 == 0) now /= 2; else{ now *= 3; now++; ans2 = max(ans2,now); } ans1++; } cout << ans1 << endl; cout << ans2 << endl; }