結果
| 問題 |
No.887 Collatz
|
| コンテスト | |
| ユーザー |
Lavender
|
| 提出日時 | 2019-09-20 21:28:19 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 379 bytes |
| コンパイル時間 | 1,710 ms |
| コンパイル使用メモリ | 166,412 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-14 16:21:52 |
| 合計ジャッジ時間 | 2,733 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main()
{
int now, ans = 0;
cin >> now;
int mx = now;
while (now != 1) {
if (now % 2 != 0) now = 3 * now + 1;
else now /= 2;
ans++;
mx = max(now, mx);
}
cout << ans << endl << mx << endl;
return 0;
}
Lavender