結果

問題 No.1233 割り切れない気持ち
ユーザー vjudge1
提出日時 2025-08-15 15:34:41
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 28 ms / 3,153 ms
コード長 538 bytes
コンパイル時間 1,734 ms
コンパイル使用メモリ 158,052 KB
実行使用メモリ 6,784 KB
最終ジャッジ日時 2025-08-15 15:34:45
合計ジャッジ時間 4,048 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
using ll = long long;

const int MAXN = 2e5 + 25;

int n;
ll ans;
int a[MAXN];
ll c[MAXN];
int cnt[MAXN];

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];
    cnt[a[i]]++;
  }
  for(int i = 1; i <= 2e5; i++) {
    for(int j = i; j <= 2e5; j += i) {
      c[j] += 1LL * cnt[i] * i;
    }
    c[i] += c[i - 1];
  }
  for(int i = 1; i <= n; i++) {
    ans += 1LL * a[i] * n - c[a[i]];
  }
  cout << ans;
  return 0;
}
0