結果
| 問題 |
No.887 Collatz
|
| コンテスト | |
| ユーザー |
toyama
|
| 提出日時 | 2019-09-20 21:30:53 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 741 bytes |
| コンパイル時間 | 874 ms |
| コンパイル使用メモリ | 82,416 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-14 16:27:20 |
| 合計ジャッジ時間 | 1,718 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;
int main() {
int n;
int i1 = 0;
int nmax = 1;
cin >> n;
while (n != 1) {
nmax = max(n, nmax);
i1++;
if (n & 1) n = 3 * n + 1;
else n = n / 2;
}
cout << i1 << endl;
cout << nmax << endl;
return 0;
}
toyama