結果

問題 No.887 Collatz
ユーザー ongakucasongakucas
提出日時 2019-12-12 15:46:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 408 bytes
コンパイル時間 1,484 ms
コンパイル使用メモリ 163,432 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-07 08:02:11
合計ジャッジ時間 2,757 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 WA -
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 WA -
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 WA -
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:13:12: 警告: ‘n0’ is used uninitialized [-Wuninitialized]
   13 |   int i1=0,M=n0;
      |            ^
main.cpp:12:7: 備考: ‘n0’ はここで宣言されています
   12 |   int n0;
      |       ^~

ソースコード

diff #

#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n-1;i++)
typedef long long ll;

int main(){
  int n0;
  int i1=0,M=n0;
  cin >> n0;
  while(n0>1){
    if(n0%2==0){
      n0/=2;
    }else{
      n0 = 3*n0+1;
    }
    ++i1;
    M = max(n0,M);
  }
  cout << i1 << endl << M << endl;
}
0