結果
| 問題 |
No.887 Collatz
|
| コンテスト | |
| ユーザー |
MarcusAureliusAntoninus
|
| 提出日時 | 2019-09-20 21:51:34 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 307 bytes |
| コンパイル時間 | 2,143 ms |
| コンパイル使用メモリ | 192,664 KB |
| 最終ジャッジ日時 | 2025-01-07 18:43:45 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 4 WA * 24 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:19: warning: format ‘%lld’ expects argument of type ‘long long int*’, but argument 2 has type ‘int64_t*’ {aka ‘long int*’} [-Wformat=]
6 | scanf("%lld", &n);
| ~~~^ ~~
| | |
| | int64_t* {aka long int*}
| long long int*
| %ld
main.cpp:17:24: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘int64_t’ {aka ‘long int’} [-Wformat=]
17 | printf("%d\n%lld\n", i1, n_max);
| ~~~^ ~~~~~
| | |
| | int64_t {aka long int}
| long long int
| %ld
main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
6 | scanf("%lld", &n);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
int main()
{
int64_t n;
scanf("%lld", &n);
int i1{-1};
int64_t n_max{n};
for (int i{}; i <= 400; i++)
{
if (i1 < 0 && n == 1) i1 = i;
if (n & 1) n = 3 * n + 1;
else n /= 2;
if (i <= i1)
n_max = std::max(n, n_max);
}
printf("%d\n%lld\n", i1, n_max);
return 0;
}
MarcusAureliusAntoninus