結果

問題 No.1233 割り切れない気持ち
ユーザー vjudge1vjudge1
提出日時 2024-05-02 17:52:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,310 ms / 3,153 ms
コード長 633 bytes
コンパイル時間 558 ms
コンパイル使用メモリ 67,712 KB
実行使用メモリ 6,656 KB
最終ジャッジ日時 2024-05-02 17:52:23
合計ジャッジ時間 17,670 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,248 KB
testcase_01 AC 4 ms
5,376 KB
testcase_02 AC 4 ms
5,376 KB
testcase_03 AC 4 ms
5,376 KB
testcase_04 AC 5 ms
5,376 KB
testcase_05 AC 4 ms
5,376 KB
testcase_06 AC 5 ms
5,376 KB
testcase_07 AC 214 ms
5,376 KB
testcase_08 AC 440 ms
5,504 KB
testcase_09 AC 1,121 ms
6,272 KB
testcase_10 AC 1,191 ms
6,144 KB
testcase_11 AC 170 ms
5,376 KB
testcase_12 AC 1,498 ms
6,528 KB
testcase_13 AC 1,457 ms
6,528 KB
testcase_14 AC 1,482 ms
6,528 KB
testcase_15 AC 1,494 ms
6,528 KB
testcase_16 AC 1,490 ms
6,528 KB
testcase_17 AC 16 ms
5,632 KB
testcase_18 AC 2,310 ms
6,528 KB
testcase_19 AC 22 ms
5,760 KB
testcase_20 AC 15 ms
5,760 KB
testcase_21 AC 17 ms
5,888 KB
testcase_22 AC 17 ms
5,888 KB
testcase_23 AC 17 ms
5,888 KB
testcase_24 AC 17 ms
5,632 KB
testcase_25 AC 17 ms
5,632 KB
testcase_26 AC 17 ms
5,632 KB
testcase_27 AC 21 ms
6,528 KB
testcase_28 AC 20 ms
6,272 KB
testcase_29 AC 21 ms
6,400 KB
testcase_30 AC 20 ms
6,272 KB
testcase_31 AC 20 ms
6,272 KB
testcase_32 AC 20 ms
6,272 KB
testcase_33 AC 21 ms
6,400 KB
testcase_34 AC 20 ms
6,272 KB
testcase_35 AC 20 ms
6,144 KB
testcase_36 AC 19 ms
6,272 KB
testcase_37 AC 3 ms
5,376 KB
testcase_38 AC 15 ms
5,632 KB
testcase_39 AC 1,152 ms
6,656 KB
testcase_40 AC 1,174 ms
6,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std; 

const int N = 2e5 + 5;

int t, n, vis[N], a[N];

long long ans, sum[N], tmp;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		vis[a[i]]++;
		sum[a[i]] += a[i];
		ans += a[i];
	}
	for (int i = 1; i <= 200000; i++) {
		sum[i] += sum[i - 1];
	}
	ans *= n;
	for (int i = 1; i <= 200000; i++) {
		if (!vis[i]) {
			continue;
		}
		tmp = 0;
		for (int l = 1, r = 0; l <= i; l = r + 1) {
			r = i / (i / l);
			tmp += 1ll * (i / l) * (sum[r] - sum[l - 1]);
		}
		ans -= 1ll * tmp * vis[i];
	}
	cout << ans;
	return 0;
}
0