結果

問題 No.2229 Treasure Searching Rod (Hard)
ユーザー 👑 chro_96chro_96
提出日時 2023-02-24 22:55:15
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 822 bytes
コンパイル時間 1,158 ms
コンパイル使用メモリ 27,900 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-10-11 06:45:21
合計ジャッジ時間 4,282 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,372 KB
testcase_01 AC 1 ms
4,372 KB
testcase_02 AC 0 ms
4,372 KB
testcase_03 AC 0 ms
4,372 KB
testcase_04 AC 1 ms
4,368 KB
testcase_05 AC 0 ms
4,372 KB
testcase_06 AC 1 ms
4,372 KB
testcase_07 AC 62 ms
4,368 KB
testcase_08 AC 69 ms
4,368 KB
testcase_09 AC 64 ms
4,372 KB
testcase_10 AC 62 ms
4,372 KB
testcase_11 AC 61 ms
4,368 KB
testcase_12 AC 34 ms
4,368 KB
testcase_13 AC 35 ms
4,368 KB
testcase_14 AC 32 ms
4,372 KB
testcase_15 AC 71 ms
4,372 KB
testcase_16 AC 71 ms
4,372 KB
testcase_17 AC 69 ms
4,372 KB
testcase_18 AC 71 ms
4,376 KB
testcase_19 AC 70 ms
4,368 KB
testcase_20 AC 71 ms
4,372 KB
testcase_21 AC 70 ms
4,372 KB
testcase_22 AC 70 ms
4,372 KB
testcase_23 AC 28 ms
4,376 KB
testcase_24 AC 36 ms
4,376 KB
testcase_25 AC 42 ms
4,372 KB
testcase_26 AC 17 ms
4,372 KB
testcase_27 AC 7 ms
4,376 KB
testcase_28 AC 57 ms
4,372 KB
testcase_29 AC 54 ms
4,372 KB
testcase_30 AC 8 ms
4,368 KB
testcase_31 AC 15 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main () {
  int h = 0;
  long long w = 0LL;
  int k = 0;
  long long x = 0LL;
  long long y = 0LL;
  long long v = 0LL;
  
  int res = 0;
  
  long long ans = 0LL;
  long long mod_num = 998244353LL;
  
  res = scanf("%d", &h);
  res = scanf("%lld", &w);
  res = scanf("%d", &k);
  for (int i = 0; i < k; i++) {
    long long cnt = 0LL;
    res = scanf("%lld", &x);
    res = scanf("%lld", &y);
    res = scanf("%lld", &v);
    cnt = (x*x)%mod_num;
    if (x-y > 0LL) {
      cnt -= (((x-y)*(x-y+1LL))/2LL)%mod_num;
      cnt += mod_num;
      cnt %= mod_num;
    }
    if (x-(w-y+1LL) > 0LL) {
      cnt -= (((x-(w-y+1LL))*(x-(w-y+1LL)+1LL))/2LL)%mod_num;
      cnt += mod_num;
      cnt %= mod_num;
    }
    ans += cnt*v;
    ans %= mod_num;
  }
  
  printf("%lld\n", ans%mod_num);
  return 0;
}
0