結果

問題 No.2793 Mancala Master
ユーザー kotatsugame
提出日時 2024-06-28 20:59:00
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 491 bytes
コンパイル時間 783 ms
コンパイル使用メモリ 68,472 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-28 20:59:03
合計ジャッジ時間 2,803 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cassert>
#include<atcoder/modint>
using namespace std;
using mint=atcoder::modint998244353;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int T;cin>>T;
	for(;T--;)
	{
		int N,KK;
		cin>>N>>KK;
		mint K=KK;
		long sum=0;
		for(int i=1;i<=N;i++)
		{
			int A;cin>>A;
			sum+=(long)i*A;
			sum%=998244353-1;
		}
		mint t=1,p=1,k=K.inv();
		for(int i=1;i<=N;i++)
		{
			t*=p;
			p+=k.pow(i);
		}
		cout<<(K.pow(sum)*(1-k).pow(N)*t).val()<<"\n";
	}
}
0