結果

問題 No.1233 割り切れない気持ち
ユーザー msm1993msm1993
提出日時 2020-10-06 11:47:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 73 ms / 3,153 ms
コード長 616 bytes
コンパイル時間 474 ms
コンパイル使用メモリ 65,700 KB
実行使用メモリ 8,968 KB
最終ジャッジ日時 2023-09-27 06:30:41
合計ジャッジ時間 6,607 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,432 KB
testcase_01 AC 15 ms
7,460 KB
testcase_02 AC 16 ms
7,588 KB
testcase_03 AC 16 ms
7,588 KB
testcase_04 AC 16 ms
7,452 KB
testcase_05 AC 16 ms
7,464 KB
testcase_06 AC 16 ms
7,492 KB
testcase_07 AC 29 ms
7,660 KB
testcase_08 AC 38 ms
7,804 KB
testcase_09 AC 60 ms
8,456 KB
testcase_10 AC 63 ms
8,588 KB
testcase_11 AC 28 ms
7,676 KB
testcase_12 AC 70 ms
8,852 KB
testcase_13 AC 70 ms
8,968 KB
testcase_14 AC 70 ms
8,912 KB
testcase_15 AC 70 ms
8,848 KB
testcase_16 AC 69 ms
8,804 KB
testcase_17 AC 43 ms
8,232 KB
testcase_18 AC 69 ms
8,828 KB
testcase_19 AC 73 ms
7,288 KB
testcase_20 AC 43 ms
8,260 KB
testcase_21 AC 53 ms
8,216 KB
testcase_22 AC 54 ms
8,268 KB
testcase_23 AC 54 ms
8,268 KB
testcase_24 AC 54 ms
8,204 KB
testcase_25 AC 53 ms
8,204 KB
testcase_26 AC 58 ms
8,208 KB
testcase_27 AC 62 ms
8,624 KB
testcase_28 AC 61 ms
8,576 KB
testcase_29 AC 62 ms
8,512 KB
testcase_30 AC 62 ms
8,620 KB
testcase_31 AC 62 ms
8,520 KB
testcase_32 AC 62 ms
8,432 KB
testcase_33 AC 62 ms
8,424 KB
testcase_34 AC 63 ms
8,428 KB
testcase_35 AC 61 ms
8,408 KB
testcase_36 AC 62 ms
8,388 KB
testcase_37 AC 15 ms
7,692 KB
testcase_38 AC 42 ms
8,216 KB
testcase_39 AC 56 ms
8,820 KB
testcase_40 AC 57 ms
8,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int N;
int A[200000];
LL C[200001]={};
LL SC[200001]={};
LL SCC[200001]={};

int main(){
 cin>>N;
 rep(i,N) cin>>A[i];
 rep(i,N) C[A[i]]++;
 rep(i,200000) SC[i+1]=SC[i]+C[i+1];
 rep(i,200001) SCC[i]=i*C[i];
 rep(i,200000) SCC[i+1]+=SCC[i];

 LL ans=0;
 for(int i=1; i<=200000; i++){
  for(int j=0; j<=200000; j+=i){
   LL tmp = SCC[min(j+i-1,200000)] - SCC[j];
   tmp -= (SC[min(j+i-1,200000)] - SC[j]) * j;
   tmp *= C[i];
   ans += tmp;
  }
 }

 cout<<ans<<endl;

 return 0;
}
0