結果

問題 No.988 N×Mマス計算(総和)
ユーザー bal4ubal4u
提出日時 2020-02-15 21:37:46
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 853 bytes
コンパイル時間 135 ms
コンパイル使用メモリ 29,224 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 12:04:46
合計ジャッジ時間 1,279 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 0 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 4 ms
4,380 KB
testcase_12 AC 7 ms
4,380 KB
testcase_13 WA -
testcase_14 AC 3 ms
4,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 4 ms
4,380 KB
testcase_19 AC 7 ms
4,380 KB
testcase_20 AC 9 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: 関数 ‘in’ 内:
main.c:8:14: 警告: 関数 ‘getchar_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration]
    8 | #define gc() getchar_unlocked()
      |              ^~~~~~~~~~~~~~~~
main.c:12:24: 備考: in expansion of macro ‘gc’
   12 |         int n = 0, c = gc();
      |                        ^~
main.c: 関数 ‘out’ 内:
main.c:9:15: 警告: 関数 ‘putchar_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration]
    9 | #define pc(c) putchar_unlocked(c)
      |               ^~~~~~~~~~~~~~~~
main.c:20:17: 備考: in expansion of macro ‘pc’
   20 |         if (!n) pc('0');
      |                 ^~

ソースコード

diff #

// yuki 988 N×Mマス計算(総和)
// 2020.2.15 bal4u

#include <stdio.h>

typedef long long ll;

#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void out(int n) { // 非負整数の表示(出力)
	int i; char b[30];

	if (!n) pc('0');
	else {
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
    pc('\n');
}

int main()
{
    int i, j, N, M, K, op, A;
    ll B, ans;

    N = in(), M = in(), K = in();
    op = (gc() == '+'), gc();
    B = 0; for (i = 0; i < M; ++i) B += in();
    B %= K;
    ans = 0;
    for (j = 0; j < N; ++j) {
        A = in();
        if (op) ans += (B+A*M) % K;
        else    ans += A*B % K;
    }
    out((int)(ans % K));
    return 0;
}
0