結果
問題 | No.2534 コラッツ数列 |
ユーザー |
![]() |
提出日時 | 2023-11-10 21:54:39 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 397 bytes |
コンパイル時間 | 1,734 ms |
コンパイル使用メモリ | 191,212 KB |
最終ジャッジ日時 | 2025-02-17 20:41:42 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 33 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int ans = 1; while (true) { if (ans >= 100) { break; } if (n == 1) { ans += 1; break; } else { ans += 2; if (n % 2 == 0) { n /= 2; } else { n = 3 * n + 1; } } } if (n == 1 && ans <= 50) { cout << "Yes" << endl; cout << ans << endl; } else { cout << "No" << endl; } }