結果

問題 No.2952 Invision of Multiples
ユーザー nouka28nouka28
提出日時 2024-06-02 15:07:19
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,056 bytes
コンパイル時間 5,673 ms
コンパイル使用メモリ 312,928 KB
実行使用メモリ 162,104 KB
最終ジャッジ日時 2024-10-23 20:46:34
合計ジャッジ時間 121,328 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 39 TLE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#include<atcoder/all>
using namespace atcoder;
using mint=atcoder::modint998244353;

const int B=100;
const int M=200000;


mint sum[B+1],sum2[B+1];

// n>d_i
mint floor_sums[M+1][B+1];

// d_i>n
mint floor_sums2[M+1][B+1];

int main(){
	cin.tie(nullptr),ios_base::sync_with_stdio(false);
    int n,m;cin>>n>>m;
	vector<int> a(n);for(auto&e:a)cin>>e;
	mint X=1;for(auto&e:a)X*=m/e;
	for(int i=1;i<=M;i++){
		for(int j=1;j<=B;j++){
			floor_sums[i][j]=floor_sum(m/j,i,j,j-1);
			floor_sums2[i][j]=floor_sum(m/i,j,i,i-1);
		}
	}
	mint ans=0;
	fenwick_tree<mint> f(M+1);
	for(auto&e:a){
		if(e<=B){
			ans+=sum2[e];
			for(int i=1;i<=B;i++){
				ans+=sum[i]*floor_sums[e][i]/(m/e);
			}
			sum[e]+=X/(m/e);
		}else{
			for(int i=1;i<=B;i++){
				ans+=sum[i]*floor_sums[e][i]/(m/e);
			}
			for(int i=e;i<=m;i+=e){
				ans+=f.sum(i+1,m+1)/(m/e);
			}
			for(int i=1;i<=B;i++){
				sum2[i]+=X/(m/e)/(m/i)*floor_sums2[e][i];
			}
			for(int i=e;i<=M;i+=e){
				f.add(i,X/(m/e));
			}
		}
	}
	cout<<ans.val()<<endl;
}
0