結果

問題 No.1233 割り切れない気持ち
ユーザー ianCKianCK
提出日時 2020-09-23 17:23:32
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2,552 ms / 3,153 ms
コード長 642 bytes
コンパイル時間 476 ms
コンパイル使用メモリ 26,600 KB
実行使用メモリ 8,468 KB
最終ジャッジ日時 2023-09-10 07:21:18
合計ジャッジ時間 111,175 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,523 ms
6,128 KB
testcase_01 AC 2,527 ms
6,120 KB
testcase_02 AC 2,502 ms
6,124 KB
testcase_03 AC 2,507 ms
6,060 KB
testcase_04 AC 2,500 ms
6,116 KB
testcase_05 AC 2,497 ms
6,052 KB
testcase_06 AC 2,512 ms
6,172 KB
testcase_07 AC 2,515 ms
6,736 KB
testcase_08 AC 2,523 ms
8,012 KB
testcase_09 AC 2,517 ms
8,308 KB
testcase_10 AC 2,546 ms
8,348 KB
testcase_11 AC 2,532 ms
6,668 KB
testcase_12 AC 2,552 ms
8,456 KB
testcase_13 AC 2,552 ms
8,392 KB
testcase_14 AC 2,551 ms
8,468 KB
testcase_15 AC 2,531 ms
8,392 KB
testcase_16 AC 2,547 ms
8,464 KB
testcase_17 AC 2,531 ms
6,908 KB
testcase_18 AC 2,546 ms
8,396 KB
testcase_19 AC 2,548 ms
7,972 KB
testcase_20 AC 2,537 ms
6,840 KB
testcase_21 AC 2,525 ms
6,908 KB
testcase_22 AC 2,532 ms
6,896 KB
testcase_23 AC 2,549 ms
6,912 KB
testcase_24 AC 2,526 ms
6,856 KB
testcase_25 AC 2,529 ms
6,856 KB
testcase_26 AC 2,537 ms
6,932 KB
testcase_27 AC 2,543 ms
8,116 KB
testcase_28 AC 2,529 ms
8,212 KB
testcase_29 AC 2,524 ms
8,072 KB
testcase_30 AC 2,527 ms
8,160 KB
testcase_31 AC 2,529 ms
8,100 KB
testcase_32 AC 2,513 ms
8,132 KB
testcase_33 AC 2,537 ms
8,064 KB
testcase_34 AC 2,521 ms
8,132 KB
testcase_35 AC 2,537 ms
8,104 KB
testcase_36 AC 2,533 ms
8,060 KB
testcase_37 AC 2,519 ms
6,108 KB
testcase_38 AC 2,513 ms
8,004 KB
testcase_39 AC 2,542 ms
8,392 KB
testcase_40 AC 2,536 ms
8,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

typedef long long int ll;
constexpr int kN = int(2E5 + 10);

int a[kN];
ll s[kN], cnt[kN], ss[kN];

int main() {
	int n, tmp, nxt;
	ll ans = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	for (int i = 1; i <= n; i++) cnt[a[i]]++;
	for (int i = 1; i < kN; i++) s[i] = s[i - 1] + cnt[i];
	for (int i = 1; i < kN; i++) ss[i] = ss[i - 1] + i * cnt[i];
	for (int i = 1; i < kN; i++) {
		for (int j = 1; j <= i; j = nxt + 1) {
			tmp = i / j;
			nxt = i / tmp;
			ans -= tmp * cnt[i] * (ss[nxt] - ss[j - 1]);
		}
	}
	for (int i = 1; i < kN; i++) ans += s[kN - 1] * i * cnt[i];
	printf("%lld\n", ans);
}
0