結果
問題 | No.887 Collatz |
ユーザー |
|
提出日時 | 2019-09-20 21:22:09 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 677 bytes |
コンパイル時間 | 1,372 ms |
コンパイル使用メモリ | 157,700 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-14 16:08:05 |
合計ジャッジ時間 | 2,382 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
/*** author: yuji9511 ***/ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> lpair; const ll MOD = 1e9 + 7; const ll INF = 1e18; #define rep(i,m,n) for(ll i = (m); i < (n); i++) #define rrep(i,m,n) for(ll i = (m); i >= (n); i--) #define print(x) cout << (x) << endl; #define print2(x,y) cout << (x) << " " << (y) << endl; #define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];}; int main(){ cin.tie(0); ios::sync_with_stdio(false); ll N; cin >> N; ll ans = N; ll idx = 0; while(N != 1){ if(N % 2 == 0){ N /= 2; }else{ N = 3*N+1; } ans = max(ans, N); idx++; } print(idx); print(ans); }