結果

問題 No.2176 LRM Question 1
ユーザー ixTL255
提出日時 2023-01-06 22:18:21
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 544 bytes
コンパイル時間 13,033 ms
コンパイル使用メモリ 394,200 KB
実行使用メモリ 13,640 KB
最終ジャッジ日時 2024-11-30 18:30:43
合計ジャッジ時間 29,020 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 9 TLE * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).ok();
	let mut itr = s.trim().split_whitespace();
	let l: usize = itr.next().unwrap().parse().unwrap();
	let r: usize = itr.next().unwrap().parse().unwrap();	
	let m: usize = itr.next().unwrap().parse().unwrap();	

	let fact = |x| {
		let mut y = 1;
		for i in 1..=x { y *= i; }
		y
	};

	let mut ans: usize = 0;
	for i in l..=r {
		let mut x = 1;
			for j in 1..=i { x = x % m * fact(j); }
		ans = (ans + x) % m;
		if x % m == 0 { break; }
	}

	println!("{}", ans);
}
0