結果

問題 No.1233 割り切れない気持ち
ユーザー 👑 NachiaNachia
提出日時 2020-10-05 16:39:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 71 ms / 3,153 ms
コード長 616 bytes
コンパイル時間 504 ms
コンパイル使用メモリ 65,208 KB
実行使用メモリ 9,132 KB
最終ジャッジ日時 2023-09-27 03:20:26
合計ジャッジ時間 5,742 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
7,440 KB
testcase_01 AC 14 ms
7,640 KB
testcase_02 AC 14 ms
7,508 KB
testcase_03 AC 15 ms
7,500 KB
testcase_04 AC 15 ms
7,432 KB
testcase_05 AC 15 ms
7,564 KB
testcase_06 AC 15 ms
7,428 KB
testcase_07 AC 28 ms
7,632 KB
testcase_08 AC 37 ms
7,832 KB
testcase_09 AC 58 ms
8,604 KB
testcase_10 AC 61 ms
8,568 KB
testcase_11 AC 26 ms
7,616 KB
testcase_12 AC 67 ms
8,940 KB
testcase_13 AC 65 ms
8,808 KB
testcase_14 AC 66 ms
8,876 KB
testcase_15 AC 65 ms
8,864 KB
testcase_16 AC 67 ms
8,868 KB
testcase_17 AC 41 ms
8,280 KB
testcase_18 AC 69 ms
9,132 KB
testcase_19 AC 71 ms
7,316 KB
testcase_20 AC 41 ms
8,220 KB
testcase_21 AC 51 ms
8,208 KB
testcase_22 AC 50 ms
8,408 KB
testcase_23 AC 51 ms
8,280 KB
testcase_24 AC 51 ms
8,272 KB
testcase_25 AC 52 ms
8,212 KB
testcase_26 AC 51 ms
8,276 KB
testcase_27 AC 58 ms
8,648 KB
testcase_28 AC 59 ms
8,488 KB
testcase_29 AC 58 ms
8,592 KB
testcase_30 AC 58 ms
8,648 KB
testcase_31 AC 58 ms
8,496 KB
testcase_32 AC 56 ms
8,552 KB
testcase_33 AC 57 ms
8,472 KB
testcase_34 AC 57 ms
8,384 KB
testcase_35 AC 60 ms
8,588 KB
testcase_36 AC 58 ms
8,360 KB
testcase_37 AC 15 ms
7,436 KB
testcase_38 AC 40 ms
8,220 KB
testcase_39 AC 53 ms
8,880 KB
testcase_40 AC 55 ms
8,856 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