結果
問題 |
No.887 Collatz
|
ユーザー |
![]() |
提出日時 | 2019-10-07 20:49:42 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 567 bytes |
コンパイル時間 | 1,335 ms |
コンパイル使用メモリ | 157,840 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-14 15:03:37 |
合計ジャッジ時間 | 2,229 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
/* No.887 Collatz https://yukicoder.me/problems/no/887 */ #include <bits/stdc++.h> using namespace std; void collatz(long long int n) { long long int max = n; long long int i = 0; while (n != 1) { if (n % 2 == 0) { n /= 2; } else { n = 3 * n + 1; } if (max < n) { max = n; } i++; } cout << i << endl; cout << max << endl; } int main() { ios::sync_with_stdio(0); cin.tie(0); unsigned long long int n = 0; cin >> n; collatz(n); }