結果
| 問題 | No.3631 Collatz conjecture |
| コンテスト | |
| ユーザー |
forest3
|
| 提出日時 | 2026-11-02 16:09:27 |
| 言語 | C++14 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 559 bytes |
| 記録 | |
| コンパイル時間 | 1,130 ms |
| コンパイル使用メモリ | 193,164 KB |
| 実行使用メモリ | 9,916 KB |
| 最終ジャッジ日時 | 2026-11-02 16:09:31 |
| 合計ジャッジ時間 | 4,177 ms |
|
ジャッジサーバーID (参考情報) |
judge7_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 52 WA * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < b; i++)
using ll = long long;
int main(){
int n;
cin >> n;
if(n == 1) {
cout << "infinity" << endl;
return 0;
}
set<int> st;
st.insert(n);
int k = 0;
while(n != 1) {
k++;
if(n % 2 == 0) {
n /= 2;
} else {
n = 3 * n + 1;
}
if(st.count(n)) {
cout << "infinity" << endl;
return 0;
}
st.insert(n);
}
cout << k << endl;
}
forest3