結果

問題 No.933 おまわりさんこいつです
ユーザー trineutron
提出日時 2020-02-25 01:12:38
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 353 bytes
コンパイル時間 2,146 ms
コンパイル使用メモリ 191,356 KB
最終ジャッジ日時 2025-01-09 02:09:08
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other RE * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:18: warning: format ‘%ld’ expects argument of type ‘long int*’, but argument 2 has type ‘int64_t’ {aka ‘long int’} [-Wformat=]
   10 |         scanf("%ld", p);
      |                ~~^   ~
      |                  |   |
      |                  |   int64_t {aka long int}
      |                  long int*
main.cpp:18:14: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘int64_t’ {aka ‘long int’} [-Wformat=]
   18 |     printf("%d\n", ans);
      |             ~^     ~~~
      |              |     |
      |              int   int64_t {aka long int}
      |             %ld
main.cpp:6:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |         scanf("%ld", p);
      |         ~~~~~^~~~~~~~~~
main.cpp:10:14: warning: ‘p’ may be used uninitialized [-Wmaybe-uninitialized]
   10 |         scanf("%ld", p);
      |         ~~~~~^~~~~~~~~~
main.cpp:9:17: note: ‘p’ was declared here
    9 |         int64_t p;
      |                 ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    int64_t ans = 1;
    for (int i = 0; i < n; i++) {
        int64_t p;
        scanf("%ld", p);
        if (p == 0) {
            puts("0");
            return 0;
        }
        (ans *= p) %= 9;
    }
    if (ans == 0) ans = 9;
    printf("%d\n", ans);
}
0