結果

問題 No.2896 Monotonic Prime Factors
ユーザー cho435cho435
提出日時 2024-09-20 22:08:10
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 118 ms / 2,000 ms
コード長 1,273 bytes
コンパイル時間 4,624 ms
コンパイル使用メモリ 262,800 KB
実行使用メモリ 51,072 KB
最終ジャッジ日時 2024-09-20 22:08:19
合計ジャッジ時間 7,251 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, t) for (ll i = s; i < (ll)(t); i++)

template<typename T>
bool chmin(T &x, T y) { return x > y ? (x = y, true) : false; }
template<typename T>
bool chmax(T &x, T y) { return x < y ? (x = y, true) : false; }

struct io_setup {
	io_setup() {
		ios::sync_with_stdio(false);
		std::cin.tie(nullptr);
		cout << fixed << setprecision(15);
	}
} io_setup;

const int sz=2e5+10;
vector<int> pdv(sz,-1);
void init(){
	rep(i,2,sz){
		if(pdv.at(i)!=-1) continue;
		for(int j=i;j<sz;j+=i){
			pdv.at(j)=i;
		}
	}
}
const int MOD=998244353;
const int MAX_N=2e6;
vector<ll> fac(MAX_N+1,1);
vector<ll> finv(MAX_N+1,1);
vector<ll> inv(MAX_N+1,1);
void comb_setup(){
	for(int i=2;i<=MAX_N;i++){
		fac.at(i)=(fac.at(i-1)*i)%MOD;
		inv.at(i)=MOD-(inv.at(MOD%i)*(MOD/i))%MOD;
		finv.at(i)=(finv.at(i-1)*inv.at(i))%MOD;
	}
}
ll comb(int n,int k){
	if(n<k) return 0;
	return fac.at(n)*(finv.at(n-k)*finv.at(k)%MOD)%MOD;
}

int main(){
	init();
	comb_setup();
	int q;
	cin>>q;
	ll dd=0;
	auto dvmul=[&](int x){
		while(x>1){
			dd++;
			x/=pdv.at(x);
		}
	};
	auto calc=[&](int n){
		return comb(dd-1,n-1);
	};
	rep(i,0,q){
		int a,b;
		cin>>a>>b;
		dvmul(a);
		cout<<calc(b)<<"\n";
	}
}
0