結果

問題 No.1233 割り切れない気持ち
ユーザー outlineoutline
提出日時 2021-01-01 21:11:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 3,153 ms
コード長 1,688 bytes
コンパイル時間 1,274 ms
コンパイル使用メモリ 134,004 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-19 20:03:22
合計ジャッジ時間 3,824 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,816 KB
testcase_01 AC 3 ms
6,816 KB
testcase_02 AC 4 ms
6,940 KB
testcase_03 AC 6 ms
6,944 KB
testcase_04 AC 5 ms
6,940 KB
testcase_05 AC 5 ms
6,940 KB
testcase_06 AC 5 ms
6,940 KB
testcase_07 AC 12 ms
6,944 KB
testcase_08 AC 16 ms
6,944 KB
testcase_09 AC 25 ms
6,940 KB
testcase_10 AC 24 ms
6,940 KB
testcase_11 AC 11 ms
6,940 KB
testcase_12 AC 29 ms
6,944 KB
testcase_13 AC 28 ms
6,940 KB
testcase_14 AC 28 ms
6,940 KB
testcase_15 AC 28 ms
6,944 KB
testcase_16 AC 27 ms
6,944 KB
testcase_17 AC 12 ms
6,944 KB
testcase_18 AC 29 ms
6,940 KB
testcase_19 AC 20 ms
6,940 KB
testcase_20 AC 14 ms
6,940 KB
testcase_21 AC 15 ms
6,944 KB
testcase_22 AC 16 ms
6,948 KB
testcase_23 AC 16 ms
6,940 KB
testcase_24 AC 16 ms
6,940 KB
testcase_25 AC 16 ms
6,940 KB
testcase_26 AC 16 ms
6,944 KB
testcase_27 AC 18 ms
6,948 KB
testcase_28 AC 18 ms
6,940 KB
testcase_29 AC 18 ms
6,940 KB
testcase_30 AC 18 ms
6,940 KB
testcase_31 AC 18 ms
6,940 KB
testcase_32 AC 18 ms
6,944 KB
testcase_33 AC 18 ms
6,944 KB
testcase_34 AC 18 ms
6,940 KB
testcase_35 AC 18 ms
6,940 KB
testcase_36 AC 18 ms
6,944 KB
testcase_37 AC 2 ms
6,940 KB
testcase_38 AC 13 ms
6,940 KB
testcase_39 AC 21 ms
6,944 KB
testcase_40 AC 22 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <array>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

constexpr int MAX = 200000;
int dist[MAX + 5];
int distsum[MAX + 5];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin >> N;
    vector<int> A(N);
    ll S = 0;
    for(int i = 0; i < N; ++i){
        cin >> A[i];
        dist[A[i]] += 1;
        S += A[i];
    }
    for(int i = 0; i <= MAX; ++i){
        distsum[i + 1] = distsum[i] + dist[i];
    }

    ll sum = 0;
    for(int i = 1; i <= MAX; ++i){
        if(dist[i] == 0)    continue;
        ll floorsum = 0;
        for(int l = i; l <= MAX; l += i){
            int r = min(MAX + 1, l + i);
            floorsum += (ll)(distsum[r] - distsum[l]) * (l / i);
        }
        sum += floorsum * i * dist[i];
    }
    
    cout << S * N - sum << endl;

    return 0;
}
0