結果

問題 No.2046 Ans Mod? Mod Ans!
コンテスト
ユーザー taiga0629kyopro
提出日時 2022-08-19 22:04:03
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 98 ms / 4,000 ms
コード長 429 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 107 ms
コンパイル使用メモリ 85,076 KB
実行使用メモリ 116,608 KB
最終ジャッジ日時 2026-05-26 12:36:26
合計ジャッジ時間 1,967 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code


n=int(input())
a=list(map(int,input().split()))
a.sort()
cnt=[0]*(2*10**5+100)
wa=[0]*(n+3)
for i in range(n-1,-1,-1):
    cnt[a[i]]+=1
    wa[i]=wa[i+1]+a[i]
for i in range(2*10**5,-1,-1):
    cnt[i]+=cnt[i+1]
ans=0
for i in range(n):
    res=0
    res+=a[i]*(n-1-i)
    res-=wa[i+1]
    for p in range(a[i],2*10**5+1,a[i]):
        if p==a[i]:res+=a[i]*(cnt[p]-1)
        else:res+=a[i]*cnt[p]

    ans+=res
print(ans)






0