結果
問題 | No.887 Collatz |
ユーザー |
![]() |
提出日時 | 2022-10-22 16:44:33 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 303 bytes |
コンパイル時間 | 1,631 ms |
コンパイル使用メモリ | 192,500 KB |
最終ジャッジ日時 | 2025-02-08 11:25:40 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define int long longsigned main(){int N;cin>>N;int ans = N;for(int i=0;i<=1e18;i++){if(N==1){cout<<i<<endl;cout<<ans<<endl;return 0;}if(N%2) N = 3*N+1;else N /= 2;ans = max(N,ans);}}