結果
問題 | No.2534 コラッツ数列 |
ユーザー |
![]() |
提出日時 | 2023-11-24 11:31:38 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 530 bytes |
コンパイル時間 | 1,833 ms |
コンパイル使用メモリ | 191,584 KB |
最終ジャッジ日時 | 2025-02-17 23:35:46 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 33 |
ソースコード
#include <bits/stdc++.h>using namespace std;void fast_io() {ios::sync_with_stdio(false);std::cin.tie(nullptr);}int main() {fast_io();int n;cin >> n;int ans = 1;for (; ans <= 50;) {ans++;if (n == 1) {break;}if (n % 2 == 0) {n /= 2;} else {n = 3 * n + 1;}ans++;}if (ans > 50) {cout << "No\n";} else {cout << "Yes\n";cout << ans << "\n";}}