結果
問題 |
No.887 Collatz
|
ユーザー |
![]() |
提出日時 | 2019-12-12 15:46:04 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 408 bytes |
コンパイル時間 | 1,642 ms |
コンパイル使用メモリ | 165,416 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 02:23:46 |
合計ジャッジ時間 | 2,686 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 22 WA * 6 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:13:12: warning: 'n0' is used uninitialized [-Wuninitialized] 13 | int i1=0,M=n0; | ^ main.cpp:12:7: note: 'n0' declared here 12 | int n0; | ^~
ソースコード
#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; }