結果

問題 No.2558 中国剰余定理
ユーザー
提出日時 2024-05-11 22:38:41
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 397 bytes
コンパイル時間 13,005 ms
コンパイル使用メモリ 402,572 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-20 08:52:00
合計ジャッジ時間 14,621 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

fn egcd(a: i64, b: i64) -> (i64, i64) {
	if b == 0 {
		return (1, 0);
	}
	let (x, y) = egcd(b, a % b);
	(y, x - a / b * y)
}

fn main() {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).ok();
	let n: Vec<i64> = s.split_whitespace().flat_map(str::parse).collect();
	let g = egcd(n[0], n[1]);
	let l = n[0] * n[1];
	println!("{}", (g.0 * n[0] * n[3] + g.1 * n[1] * n[2] + l) % l);
}
0