結果

問題 No.1233 割り切れない気持ち
ユーザー vjudge1
提出日時 2024-05-02 12:56:32
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 640 bytes
コンパイル時間 2,014 ms
コンパイル使用メモリ 192,680 KB
最終ジャッジ日時 2025-02-21 10:34:34
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 1 WA * 37 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std; 

const int N = 2e5 + 5;

int t, n;

long long a[N], ans, maxi = 0, sum[N];

bool vis[N];

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]] = true;
		maxi = max(maxi, a[i]);
		sum[a[i]] += a[i];
		ans += a[i];
	}
	for (int i = 1; i <= maxi + 1; i++) {
		sum[i] += sum[i - 1];
	}
	ans *= n;
	for (int i = 1; i <= maxi; i++) {
		if (!vis[i]) {
			continue;
		}
		for (long long l = 1, r = 0; l <= i; l = r + 1) {
			r = i / (i / l);
			ans -= (i / l) * (sum[r] - sum[l - 1]);
		}
	}
	cout << ans;
	return 0;
}
0