結果
問題 | No.887 Collatz |
ユーザー |
|
提出日時 | 2019-10-04 21:18:15 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 405 bytes |
コンパイル時間 | 1,528 ms |
コンパイル使用メモリ | 165,192 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-03 07:00:13 |
合計ジャッジ時間 | 2,010 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)#define MAX(a, b) ((a) > (b) ? (a) : (b))#define MIN(a, b) ((a) < (b) ? (a) : (b))typedef long long ll;int main(void){ll n;cin >> n;ll max = n, cnt = 0;while(n != 1){cnt++;if(!(n%2)) n /= 2;else n = 3*n+1;max = MAX(n, max);}cout << cnt << endl << max << endl;return 0;}