結果

問題 No.2203 POWER!!!!!
コンテスト
ユーザー lam6er
提出日時 2025-03-20 21:04:03
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 437 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 229 ms
コンパイル使用メモリ 96,240 KB
実行使用メモリ 112,008 KB
最終ジャッジ日時 2026-07-07 12:42:53
合計ジャッジ時間 3,258 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n = int(input())
A = list(map(int, input().split()))

# Count the occurrences of each number (1 to 8)
count = [0] * 9
for num in A:
    count[num] += 1

# Precompute sum_pows for each a from 1 to 8
sum_pows = [0] * 9
for a in range(1, 9):
    total = 0
    for k in range(1, 9):
        total += (a ** k) * count[k]
    sum_pows[a] = total

# Calculate the total answer
answer = 0
for num in A:
    answer += sum_pows[num]

print(answer)
0