結果

問題 No.1233 割り切れない気持ち
ユーザー leaf_1415leaf_1415
提出日時 2020-09-18 21:54:17
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 33 ms / 3,153 ms
コード長 1,172 bytes
コンパイル時間 688 ms
コンパイル使用メモリ 73,672 KB
実行使用メモリ 9,896 KB
最終ジャッジ日時 2023-09-04 21:45:13
合計ジャッジ時間 3,514 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
9,804 KB
testcase_01 AC 11 ms
9,512 KB
testcase_02 AC 11 ms
9,568 KB
testcase_03 AC 11 ms
9,580 KB
testcase_04 AC 11 ms
9,516 KB
testcase_05 AC 11 ms
9,528 KB
testcase_06 AC 11 ms
9,576 KB
testcase_07 AC 16 ms
9,632 KB
testcase_08 AC 19 ms
9,736 KB
testcase_09 AC 27 ms
9,520 KB
testcase_10 AC 30 ms
9,508 KB
testcase_11 AC 15 ms
9,624 KB
testcase_12 AC 33 ms
9,612 KB
testcase_13 AC 32 ms
9,872 KB
testcase_14 AC 32 ms
9,684 KB
testcase_15 AC 31 ms
9,744 KB
testcase_16 AC 31 ms
9,632 KB
testcase_17 AC 23 ms
9,680 KB
testcase_18 AC 29 ms
9,896 KB
testcase_19 AC 30 ms
8,760 KB
testcase_20 AC 23 ms
9,612 KB
testcase_21 AC 25 ms
9,740 KB
testcase_22 AC 26 ms
9,628 KB
testcase_23 AC 26 ms
9,664 KB
testcase_24 AC 26 ms
9,688 KB
testcase_25 AC 25 ms
9,620 KB
testcase_26 AC 26 ms
9,624 KB
testcase_27 AC 28 ms
9,716 KB
testcase_28 AC 28 ms
9,676 KB
testcase_29 AC 27 ms
9,628 KB
testcase_30 AC 28 ms
9,872 KB
testcase_31 AC 28 ms
9,620 KB
testcase_32 AC 28 ms
9,684 KB
testcase_33 AC 28 ms
9,680 KB
testcase_34 AC 28 ms
9,692 KB
testcase_35 AC 28 ms
9,624 KB
testcase_36 AC 27 ms
9,740 KB
testcase_37 AC 11 ms
9,584 KB
testcase_38 AC 23 ms
9,624 KB
testcase_39 AC 26 ms
9,664 KB
testcase_40 AC 26 ms
9,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint a[200005], cnt[200005];
llint dif[400005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i], cnt[a[i]]++;
	
	for(int i = 2; i <= 200000; i++){
		for(int j = 0; j*i <= 200000; j++){
			dif[i*j+1] += cnt[i];
			dif[(j+1)*i] -= cnt[i]*i;
			dif[(j+1)*i+1] += cnt[i]*(i-1);
		}
	}
	for(int i = 1; i <= 200000; i++) dif[i] += dif[i-1];
	for(int i = 1; i <= 200000; i++) dif[i] += dif[i-1];
	
	
	llint ans = 0;
	for(int i = 1; i <= 200000; i++) ans += dif[i] * cnt[i];
	cout << ans << endl;
	
	return 0;
}
0