結果

問題 No.1140 EXPotentiaLLL!
ユーザー trineutron
提出日時 2020-08-01 23:49:38
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 624 bytes
コンパイル時間 239 ms
コンパイル使用メモリ 28,160 KB
最終ジャッジ日時 2025-01-12 13:00:22
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 10 WA * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:17: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘long int*’ [-Wformat=]
   18 |         scanf("%d %d", &a, &p);
      |                ~^      ~~
      |                 |      |
      |                 int*   long int*
      |                %ld
main.cpp:18:20: warning: format ‘%d’ expects argument of type ‘int*’, but argument 3 has type ‘long int*’ [-Wformat=]
   18 |         scanf("%d %d", &a, &p);
      |                   ~^       ~~
      |                    |       |
      |                    int*    long int*
      |                   %ld
main.cpp:15:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |     scanf("%d", &t);
      |     ~~~~~^~~~~~~~~~
main.cpp:18:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |         scanf("%d %d", &a, &p);
      |         ~~~~~^~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <cstdio>

int main() {
    bool isprime[5000001];
    isprime[1] = false;
    for (int i = 2; i <= 5000000; i++) {
        isprime[i] = true;
    }
    for (int i = 2; i * i <= 5000000; i++) {
        for (int j = 2; j * i <= 5000000; j++) {
            isprime[j * i] = false;
        }
    }
    int t;
    scanf("%d", &t);
    for (int i = 0; i < t; i++) {
        long a, p;
        scanf("%d %d", &a, &p);
        if (isprime[p]) {
            if (a % p == 0) {
                puts("0");
            } else {
                puts("1");
            }
        } else {
            puts("-1");
        }
    }
}
0