結果

問題 No.1233 割り切れない気持ち
ユーザー 👑 jupirojupiro
提出日時 2020-09-22 05:21:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 55 ms / 3,153 ms
コード長 1,683 bytes
コンパイル時間 1,343 ms
コンパイル使用メモリ 132,864 KB
実行使用メモリ 13,824 KB
最終ジャッジ日時 2023-09-07 20:04:39
合計ジャッジ時間 6,167 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,784 KB
testcase_01 AC 32 ms
10,792 KB
testcase_02 AC 32 ms
10,788 KB
testcase_03 AC 32 ms
10,780 KB
testcase_04 AC 32 ms
10,772 KB
testcase_05 AC 32 ms
10,780 KB
testcase_06 AC 33 ms
10,856 KB
testcase_07 AC 36 ms
11,116 KB
testcase_08 AC 40 ms
11,052 KB
testcase_09 AC 51 ms
11,292 KB
testcase_10 AC 51 ms
11,292 KB
testcase_11 AC 36 ms
10,776 KB
testcase_12 AC 55 ms
13,632 KB
testcase_13 AC 55 ms
13,672 KB
testcase_14 AC 54 ms
13,604 KB
testcase_15 AC 55 ms
13,548 KB
testcase_16 AC 54 ms
13,516 KB
testcase_17 AC 43 ms
11,576 KB
testcase_18 AC 49 ms
13,548 KB
testcase_19 AC 50 ms
11,584 KB
testcase_20 AC 43 ms
11,576 KB
testcase_21 AC 46 ms
11,576 KB
testcase_22 AC 47 ms
11,552 KB
testcase_23 AC 46 ms
11,628 KB
testcase_24 AC 47 ms
11,500 KB
testcase_25 AC 46 ms
11,572 KB
testcase_26 AC 46 ms
11,580 KB
testcase_27 AC 48 ms
13,544 KB
testcase_28 AC 48 ms
13,544 KB
testcase_29 AC 48 ms
13,660 KB
testcase_30 AC 47 ms
13,620 KB
testcase_31 AC 48 ms
13,672 KB
testcase_32 AC 48 ms
13,752 KB
testcase_33 AC 48 ms
13,824 KB
testcase_34 AC 48 ms
13,632 KB
testcase_35 AC 47 ms
13,548 KB
testcase_36 AC 48 ms
13,628 KB
testcase_37 AC 32 ms
10,788 KB
testcase_38 AC 44 ms
13,616 KB
testcase_39 AC 47 ms
13,672 KB
testcase_40 AC 46 ms
13,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>
#include <fstream>

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353;
constexpr int MAX = 5000000;

const int N = 200000;
ll cnt[N * 3 + 100];
ll sum[N * 3 + 100];
int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n; cin >> n;
	vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i], cnt[a[i]]++;
	for (int i = 0; i <= N * 2 + 3; i++) sum[i + 1] = sum[i] + cnt[i];
	vector<ll> SA(N + 2);
	for (ll i = 1; i <= N; i++) {
		for (ll j = i; j <= N; j += i) {
			SA[i] += (sum[j + i] - sum[j]) * (j / i);
		}
	}

	ll res = accumulate(a.begin(), a.end(), 0LL) * n;
	for (int i = 0; i < n; i++) {
		res -= a[i] * SA[a[i]];
	}
	cout << res << endl;
	return 0;
}
0