結果

問題 No.2111 Sum of Diff
ユーザー 👑 chro_96chro_96
提出日時 2022-10-28 21:43:54
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 186 ms / 2,000 ms
コード長 701 bytes
コンパイル時間 1,205 ms
コンパイル使用メモリ 29,616 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 04:35:38
合計ジャッジ時間 4,339 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 185 ms
4,376 KB
testcase_03 AC 122 ms
4,376 KB
testcase_04 AC 22 ms
4,380 KB
testcase_05 AC 185 ms
4,380 KB
testcase_06 AC 186 ms
4,376 KB
testcase_07 AC 41 ms
4,376 KB
testcase_08 AC 57 ms
4,376 KB
testcase_09 AC 10 ms
4,376 KB
testcase_10 AC 13 ms
4,380 KB
testcase_11 AC 84 ms
4,376 KB
testcase_12 AC 81 ms
4,380 KB
testcase_13 AC 51 ms
4,376 KB
testcase_14 AC 149 ms
4,376 KB
testcase_15 AC 178 ms
4,376 KB
testcase_16 AC 71 ms
4,376 KB
testcase_17 AC 184 ms
4,380 KB
testcase_18 AC 52 ms
4,380 KB
testcase_19 AC 136 ms
4,376 KB
testcase_20 AC 185 ms
4,380 KB
testcase_21 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

long long power_mod (long long a, long long b, long long mod_num) {
  long long ans = 1LL;
  
  if (b > 0LL) {
    ans = power_mod(a, b/2LL, mod_num);
    ans = (ans * ans) % mod_num;
    if (b%2LL == 1LL) {
      ans = (ans * a) % mod_num;
    }
  }
  
  return ans;
}

int main () {
  int n = 0;
  
  int res = 0;
  
  long long ans = 0LL;
  long long mod_num = 998244353LL;
  
  res = scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    long long a = 0LL;
    res = scanf("%lld", &a);
    ans += (a*power_mod(2LL, (long long)(n-i-1), mod_num))%mod_num;
    ans += mod_num-(a*power_mod(2LL, (long long)i, mod_num))%mod_num;
  }
  
  printf("%lld\n", ans%mod_num);
  return 0;
}
0