結果

問題 No.1559 Next Rational
ユーザー tailstails
提出日時 2021-07-01 09:56:47
言語 cLay
(20240104-1)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 244 bytes
コンパイル時間 4,528 ms
コンパイル使用メモリ 189,288 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-19 02:29:51
合計ジャッジ時間 5,293 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

{
	ll@n;Mint@a,@b,@k;
	Polynomial<Mint> p,m,r;
	p.change(1,1);
	m.change(2,1);
	m.change(1,-(a*a+b*b+k)/(a*b));
	m.change(0,1);
	r.change(0,1);
	n-=1;
	while(n){
		if(n&1){
			r=r*p%m;
		}
		n>>=1;
		p=p*p%m;
	}
	wt(r.coef(0)*a+r.coef(1)*b);
}
0