結果

問題 No.391 CODING WAR
ユーザー At-sushiAt-sushi
提出日時 2020-06-02 17:11:57
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 645 bytes
コンパイル時間 13,011 ms
コンパイル使用メモリ 403,964 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-03 06:23:05
合計ジャッジ時間 14,152 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 1 ms
5,376 KB
testcase_05 RE -
testcase_06 AC 1 ms
5,376 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 1 ms
5,376 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused return value of `collect` that must be used
  --> src/main.rs:19:2
   |
19 | /     (1..m).map(|i| {
20 | |         let patterns = (m-i).pow(n as u32);
21 | |         let zeros = nfactorial(m, i) / nfactorial(i, i);
22 | |         
23 | |         if i % 2 == 0 {r += patterns * zeros} else {r -= patterns * zeros};
24 | |     }).collect::<()>();
   | |______________________^
   |
   = note: if you really need to exhaust the iterator, consider `.for_each(drop)` instead
   = note: `#[warn(unused_must_use)]` on by default
help: use `let _ = ...` to ignore the resulting value
   |
19 |     let _ = (1..m).map(|i| {
   |     +++++++

ソースコード

diff #

fn getline() -> String{
	let mut __ret=String::new();
	std::io::stdin().read_line(&mut __ret).ok();
	return __ret;
}

fn nfactorial(x: i64, y: i64) -> i64 {
    match y {
        0 => 1,
        _ => x * nfactorial(x-1, y-1)
    }
}

fn main(){
	let s=getline();
	let a:Vec<_>=s.trim().split(' ').collect();
	let (n, m): (i64, i64) = (a[0].parse().unwrap(), a[1].parse().unwrap());
	let mut r = m.pow(n as u32);
	(1..m).map(|i| {
	    let patterns = (m-i).pow(n as u32);
	    let zeros = nfactorial(m, i) / nfactorial(i, i);
	    
	    if i % 2 == 0 {r += patterns * zeros} else {r -= patterns * zeros};
	}).collect::<()>();
	print!("{} ", r);
}
0