結果
| 問題 |
No.887 Collatz
|
| コンテスト | |
| ユーザー |
Cinnamoroll
|
| 提出日時 | 2019-09-20 22:11:13 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 4,818 bytes |
| コンパイル時間 | 1,550 ms |
| コンパイル使用メモリ | 165,448 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-14 17:53:54 |
| 合計ジャッジ時間 | 2,462 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
// warm heart, wagging tail,and a smile just for you!
//
// ▒█████▒▒
// ██████████▒
// ▒████████████▒
// ██████████████████
// ████████████████████▒
// ▒██████████████████████▒
// ▒███████████████████████
// ▒████▒▒▒▒▒▒█████████████████▒
// ███▒▒▒▒▒▒██████████████████████▒▒▒
// ▒██▒▒███████████████████████▒▒▒▒▒██████
// ▒█████████████████████████▒▒▒▒▒▒█████████▒
// ▒█████████████████████▒▒▒▒▒▒██████████████
// ▒████ ████▒▒▒▒▒████ ████▒
// ▒█████▒ ████ ▒▒▒▒███████ ████ ██████▒
// ▒██▒▒▒▒▒ ██████ █████████ ██████ ██▒▒▒██▒
// █████████ ████████ █████████ ████████ ▒▒▒▒█████
// ▒█████████ ██████ ████████▒ ██████ █████████
// ▒██████████ ████ █████▒▒▒▒▒▒ ████ ██████████
// ████████████ ▒▒▒▒▒▒▒████████ ███████████▒
// ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
// ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
// ▒▒▒▒▒▒▒▒▒██████████████ ███████▒▒▒▒███████████
// █████████████████████████ ███████▒▒▒██████████████▒
// █████████████████████████████ ███████▒▒▒██████████████████▒
// ██████████████████████████████████████████████████████████████████████
// ██████████████████████████████████████████████████████████████████▒
// ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define SP << " " <<
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
int now = 0, mx = n;
while(n!=1){
if(n&1) n = 3*n+1;
else n /= 2;
mx = max(mx,n);
now++;
}
cout << now << endl << mx << endl;
return 0;
}
Cinnamoroll