結果
| 問題 | 
                            No.887 Collatz
                             | 
                    
| コンテスト | |
| ユーザー | 
                             tko919
                         | 
                    
| 提出日時 | 2019-09-21 16:25:09 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 799 bytes | 
| コンパイル時間 | 1,813 ms | 
| コンパイル使用メモリ | 164,752 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-09-19 01:33:18 | 
| 合計ジャッジ時間 | 2,758 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 3 | 
| other | WA * 28 | 
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:25:11: warning: 'cnt' may be used uninitialized [-Wmaybe-uninitialized]
   25 |     printf("%d",cnt);
      |     ~~~~~~^~~~~~~~~~
main.cpp:19:11: note: 'cnt' was declared here
   19 |     int n,cnt; scanf("%d",&n);
      |           ^~~
            
            ソースコード
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end
int main(){
    int n,cnt; scanf("%d",&n);
    while(n!=1){
        if(n&1)n=3*n+1;
        else n/=2;
        cnt++;
    }
    printf("%d",cnt);
    return 0;
}
            
            
            
        
            
tko919