結果
問題 |
No.1233 割り切れない気持ち
|
ユーザー |
![]() |
提出日時 | 2021-07-26 22:27:49 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 1,290 ms / 3,153 ms |
コード長 | 1,021 bytes |
コンパイル時間 | 98 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 51,168 KB |
最終ジャッジ日時 | 2024-07-22 13:25:04 |
合計ジャッジ時間 | 21,695 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 39 |
ソースコード
import sys # sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = 10**16 md = 998244353 # md = 10**9+7 from functools import lru_cache mx = 200005 n = II() aa = LI() cnt = [0]*mx for a in aa: cnt[a] += 1 cs = [0] for c in cnt: cs.append(cs[-1]+c) @lru_cache(None) def f(a): res = 0 for i in range(1, mx): l, r = i*a, (i+1)*a if r >= mx: r = mx-1 res += (cs[r]-cs[l])*i if r == mx-1: break return res s = sum(aa) ans = s*n for a in aa: ans -= a*f(a) print(ans)