結果
問題 | No.887 Collatz |
ユーザー |
![]() |
提出日時 | 2019-10-07 20:36:55 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 557 bytes |
コンパイル時間 | 1,319 ms |
コンパイル使用メモリ | 157,776 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-14 14:44:50 |
合計ジャッジ時間 | 2,572 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 WA * 1 |
ソースコード
/* 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 = -1; long long int i = 0; while (n != 1) { if (max < n) max = n; if (n % 2 == 0) { n /= 2; } else { n = 3 * n + 1; } 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); }