結果

問題 No.1233 割り切れない気持ち
ユーザー 沙耶花沙耶花
提出日時 2020-09-18 21:56:55
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 167 ms / 3,153 ms
コード長 716 bytes
コンパイル時間 2,173 ms
コンパイル使用メモリ 202,872 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2023-09-04 19:07:11
合計ジャッジ時間 6,967 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
7,764 KB
testcase_01 AC 11 ms
7,940 KB
testcase_02 AC 30 ms
7,812 KB
testcase_03 AC 52 ms
7,972 KB
testcase_04 AC 44 ms
7,884 KB
testcase_05 AC 34 ms
7,944 KB
testcase_06 AC 38 ms
7,904 KB
testcase_07 AC 88 ms
7,816 KB
testcase_08 AC 97 ms
7,816 KB
testcase_09 AC 122 ms
7,868 KB
testcase_10 AC 124 ms
7,936 KB
testcase_11 AC 79 ms
7,936 KB
testcase_12 AC 134 ms
7,756 KB
testcase_13 AC 129 ms
7,760 KB
testcase_14 AC 132 ms
7,812 KB
testcase_15 AC 135 ms
7,944 KB
testcase_16 AC 138 ms
7,932 KB
testcase_17 AC 38 ms
7,940 KB
testcase_18 AC 167 ms
7,760 KB
testcase_19 AC 67 ms
7,772 KB
testcase_20 AC 43 ms
7,812 KB
testcase_21 AC 51 ms
7,936 KB
testcase_22 AC 51 ms
7,880 KB
testcase_23 AC 51 ms
7,812 KB
testcase_24 AC 50 ms
7,884 KB
testcase_25 AC 50 ms
7,872 KB
testcase_26 AC 50 ms
7,884 KB
testcase_27 AC 58 ms
7,760 KB
testcase_28 AC 57 ms
7,876 KB
testcase_29 AC 57 ms
7,760 KB
testcase_30 AC 57 ms
7,756 KB
testcase_31 AC 58 ms
7,812 KB
testcase_32 AC 57 ms
7,760 KB
testcase_33 AC 57 ms
7,768 KB
testcase_34 AC 57 ms
7,932 KB
testcase_35 AC 57 ms
7,936 KB
testcase_36 AC 57 ms
7,936 KB
testcase_37 AC 12 ms
7,808 KB
testcase_38 AC 43 ms
7,812 KB
testcase_39 AC 103 ms
7,872 KB
testcase_40 AC 103 ms
7,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/fenwicktree>
using namespace atcoder;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000


int main(){

	vector<long long> A(200001,0LL);
	int N;
	cin>>N;
	rep(i,N){
		int a;
		cin>>a;
		A[a] ++;
	}
	
	fenwick_tree<long long> B0(A.size());
	rep(i,A.size())B0.add(i,A[i]);
	
	fenwick_tree<long long> B1(A.size());
	rep(i,A.size())B1.add(i,A[i]*i);
	
	long long ans = 0LL;
	
	rep(i,A.size()){
		if(A[i]==0)continue;
		long long temp = 0LL;
		for(int j=0;j<A.size();j+=i){
			int r  =min(j+i,(int)A.size());
			temp += B1.sum(j,r) - B0.sum(j,r) * j;
		}
		
		ans += temp * A[i];
	}
	
	cout<<ans<<endl;

	return 0;
}

0