結果

問題 No.2046 Ans Mod? Mod Ans!
ユーザー 箱星箱星
提出日時 2021-07-18 22:19:40
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 562 bytes
コンパイル時間 1,780 ms
コンパイル使用メモリ 194,868 KB
最終ジャッジ日時 2025-01-23 03:13:46
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 TLE * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n, 0);
    int m = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        m = max(m, a[i]);
    }
    vector<int> c(m + 1, 0);
    for (int i = 0; i < n; i++) {
        c[a[i]]++;
    }
    ll ans = 0;
    for (int i = 1; i <= m; i++) {
        for (int j = i; j <= m; j++) {
            ans += c[i] * c[j] * abs(i % j - j % i);
        }
    }
    cout << ans << endl;
}
0