結果
| 問題 |
No.2046 Ans Mod? Mod Ans!
|
| コンテスト | |
| ユーザー |
houren
|
| 提出日時 | 2022-08-19 23:15:57 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 48 ms / 4,000 ms |
| コード長 | 1,095 bytes |
| コンパイル時間 | 1,791 ms |
| コンパイル使用メモリ | 167,884 KB |
| 実行使用メモリ | 7,936 KB |
| 最終ジャッジ日時 | 2024-12-16 08:29:35 |
| 合計ジャッジ時間 | 2,968 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define fix(x) fixed << setprecision(x)
#define asc(x) x, vector<x>, greater<x>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;}
const int MAX = 200000;
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<ll> cnt(200200,0), tot(200200,0), sum(200200,0);
rep(i,n){
ll a;
cin >> a;
cnt[a]++, tot[a]++;
sum[a] += a;
}
rep(i,MAX) tot[i+1] += tot[i], sum[i+1] += sum[i];
ll ans = 0;
for(int i=1;i<=MAX;i++){
ans += (tot[MAX] - tot[i])*cnt[i] * i;
for(int j=2;;j++){
int x = min(i*j-1, MAX), y = i*(j-1);
ll z = sum[x]-sum[y] - (tot[x]-tot[y])*y;
z *= cnt[i];
ans -= z;
if(x==MAX) break;
}
}
cout << ans << '\n';
return 0;
}
houren