結果
| 問題 |
No.887 Collatz
|
| コンテスト | |
| ユーザー |
hyanma
|
| 提出日時 | 2019-10-05 16:07:54 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 330 bytes |
| コンパイル時間 | 267 ms |
| コンパイル使用メモリ | 22,528 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-06 02:56:33 |
| 合計ジャッジ時間 | 1,240 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 WA * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
8 | scanf("%d", &n0);
| ~~~~~^~~~~~~~~~~
ソースコード
#include "stdio.h"
int main(){
int n0;
int i;
int max = 1;
scanf("%d", &n0);
for(i=1;i > 0;i++){
if(n0 > max){
max = n0;
}
if(n0%2 == 0){
n0 /= 2;
}else{
n0 = 3 * n0 + 1;
}
if(n0 == 1){
printf("%d\n", i);
break;
}
}
printf("%d\n", max);
return 0;
}
hyanma