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