結果
| 問題 | No.2534 コラッツ数列 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-11-10 21:27:39 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 765 bytes |
| 記録 | |
| コンパイル時間 | 2,149 ms |
| コンパイル使用メモリ | 191,628 KB |
| 最終ジャッジ日時 | 2025-02-17 20:24:26 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 WA * 10 TLE * 1 -- * 21 |
ソースコード
#include <bits/stdc++.h>
#define int long long
using namespace std;
using ll = long long;
void solve();
template<typename ...Args>
void println(Args... args) {
apply([](auto &&... args) { ((cout << args << ' '), ...); }, tuple(args...));
cout << '\n';
}
int32_t main() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
int t = 1;
// cin >> t;
for (int tc = 0; tc < t; ++tc) {
solve();
}
return 0;
}
void solve() {
int n;
cin >> n;
if (n == 0) {
cout << "No\n";
return;
}
__int128 a = n;
int cnt = 0;
while (a != 1) {
if (a % 2 == 0) a /= 2; else a = 3 * a + 1;
cnt++;
}
if (cnt <= 50)
cout << "Yes\n" << cnt << '\n'; else cout << "No\n";
}