結果

問題 No.2818 A Game I Play to Pass the Time
ユーザー highlighterhighlighter
提出日時 2024-04-27 16:31:05
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 420 ms / 2,000 ms
コード長 948 bytes
コンパイル時間 3,442 ms
コンパイル使用メモリ 174,592 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-27 16:31:54
合計ジャッジ時間 18,471 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 420 ms
6,944 KB
testcase_02 AC 409 ms
6,944 KB
testcase_03 AC 410 ms
6,940 KB
testcase_04 AC 413 ms
6,944 KB
testcase_05 AC 409 ms
6,940 KB
testcase_06 AC 412 ms
5,376 KB
testcase_07 AC 405 ms
5,376 KB
testcase_08 AC 408 ms
5,376 KB
testcase_09 AC 406 ms
5,376 KB
testcase_10 AC 407 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 320 ms
5,376 KB
testcase_13 AC 205 ms
5,376 KB
testcase_14 AC 269 ms
5,376 KB
testcase_15 AC 341 ms
5,376 KB
testcase_16 AC 323 ms
5,376 KB
testcase_17 AC 331 ms
5,376 KB
testcase_18 AC 298 ms
5,376 KB
testcase_19 AC 298 ms
5,376 KB
testcase_20 AC 363 ms
5,376 KB
testcase_21 AC 349 ms
5,376 KB
testcase_22 AC 391 ms
5,376 KB
testcase_23 AC 268 ms
5,376 KB
testcase_24 AC 255 ms
5,376 KB
testcase_25 AC 254 ms
5,376 KB
testcase_26 AC 245 ms
5,376 KB
testcase_27 AC 358 ms
5,376 KB
testcase_28 AC 366 ms
5,376 KB
testcase_29 AC 318 ms
5,376 KB
testcase_30 AC 320 ms
5,376 KB
testcase_31 AC 324 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int prime[25]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};

int main(){
	int M,Q;
	scanf("%d%d",&M,&Q);
	mint inv[61];
	inv[1]=1;
	for(int i=2;i<61;i++){
		inv[i]=-inv[998244353%i]*(998244353/i);
	}
	for(;Q--;){
		long long N,S;
		scanf("%lld%lld",&N,&S);
		std::vector<std::pair<int,int>> vec;
		for(int i=0;i<M;i++){
			if(N%prime[i]){
				continue;
			}
			int count=0;
			while(N%prime[i]==0){
				N/=prime[i];
				count++;
			}
			vec.emplace_back(std::make_pair(prime[i],count));
		}
		mint ans=1;
		for(auto p : vec){
			std::vector<mint> data(p.second+1);
			data[0]=1;
			for(int i=1;i<=p.second;i++){
				data[i]=data[i-1]*p.first;
			}
			mint res=data[p.second];
			mint mem=1;
			for(int i=1;i<=p.second;i++){
				mem*=inv[i]*(S-2+i);
				res+=data[p.second-i]*mem;
			}
			ans*=res;
		}
		ans*=S;
		printf("%d\n",ans.val());
	}
}
0