結果

問題 No.2111 Sum of Diff
ユーザー simansiman
提出日時 2022-10-30 02:21:51
言語 Ruby
(3.3.0)
結果
AC  
実行時間 346 ms / 2,000 ms
コード長 205 bytes
コンパイル時間 36 ms
コンパイル使用メモリ 11,296 KB
実行使用メモリ 28,676 KB
最終ジャッジ日時 2023-09-21 03:21:33
合計ジャッジ時間 6,790 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,008 KB
testcase_01 AC 82 ms
15,148 KB
testcase_02 AC 346 ms
28,452 KB
testcase_03 AC 259 ms
24,272 KB
testcase_04 AC 118 ms
16,740 KB
testcase_05 AC 345 ms
28,480 KB
testcase_06 AC 344 ms
28,428 KB
testcase_07 AC 142 ms
18,384 KB
testcase_08 AC 167 ms
19,724 KB
testcase_09 AC 96 ms
15,552 KB
testcase_10 AC 102 ms
16,120 KB
testcase_11 AC 211 ms
21,840 KB
testcase_12 AC 207 ms
21,360 KB
testcase_13 AC 163 ms
19,152 KB
testcase_14 AC 304 ms
26,068 KB
testcase_15 AC 336 ms
27,732 KB
testcase_16 AC 185 ms
20,544 KB
testcase_17 AC 344 ms
28,676 KB
testcase_18 AC 159 ms
19,504 KB
testcase_19 AC 278 ms
25,144 KB
testcase_20 AC 345 ms
28,628 KB
testcase_21 AC 86 ms
15,264 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:8: warning: assigned but unused variable - m
Syntax OK

ソースコード

diff #

N = gets.to_i
A = gets.split.map(&:to_i)
MOD = 998_244_353

ans = 0

A.each_with_index do |a, i|
  m = (N - i - 1)

  ans += a * 2.pow(N - i - 1, MOD)
  ans -= a * 2.pow(i, MOD)
  ans %= MOD
end

puts ans
0