結果
| 問題 |
No.887 Collatz
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-09-20 21:36:51 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 686 bytes |
| コンパイル時間 | 693 ms |
| コンパイル使用メモリ | 87,172 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-14 16:47:53 |
| 合計ジャッジ時間 | 1,652 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <cmath>
#include<iomanip>
#include <unordered_map>
#include <map>
using namespace std;
static const long long MOD = 1000000007LL;
typedef long long ll;
unordered_map <string,int> ump;
int main()
{
int n0;
cin>>n0;
int n=n0;
if(n0==1)
{cout<<0<<endl;
n=1;}
else
{
int cnt=0;
while(n0!=1)
{
if(n0%2==0)
n0/=2;
else
n0=n0*3+1;
if(n<n0)
n=n0;
cnt++;
}
cout<<cnt<<endl;
}
cout<<n<<endl;
return 0;
}