結果

問題 No.1233 割り切れない気持ち
ユーザー tko919
提出日時 2021-08-27 17:47:23
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 71 ms / 3,153 ms
コード長 879 bytes
コンパイル時間 1,735 ms
コンパイル使用メモリ 194,524 KB
最終ジャッジ日時 2025-01-24 02:17:22
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
using ll=long long int;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

ll cnt[201010];

int main(){
   int n;
   cin>>n;
   vector<ll> a(n);
   rep(i,0,n)cin>>a[i];

   ll res=0;
   rep(i,0,n){
      res+=a[i];
      cnt[a[i]]++;
   }
   res*=n;
   rep(x,0,201000)cnt[x+1]+=cnt[x];
   rep(y,1,200001){
      for(ll x=1;;x++){
         ll L=x*y-1,R=min((x+1)*y-1,200010LL);
         if(L>200010)break;
         res-=(cnt[y]-cnt[y-1])*y*(cnt[R]-cnt[L])*x;
      }
   }
   cout<<res<<'\n';
   return 0;
}
0