結果
問題 |
No.1336 Union on Blackboard
|
ユーザー |
![]() |
提出日時 | 2021-01-15 23:37:26 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 707 bytes |
コンパイル時間 | 12,043 ms |
コンパイル使用メモリ | 400,476 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-26 18:36:45 |
合計ジャッジ時間 | 13,089 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 31 |
コンパイルメッセージ
warning: unnecessary parentheses around assigned value --> src/main.rs:25:20 | 25 | ans *= (a[i] + 1); | ^ ^ | = note: `#[warn(unused_parens)]` on by default help: remove these parentheses | 25 - ans *= (a[i] + 1); 25 + ans *= a[i] + 1; |
ソースコード
fn read<T: std::str::FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec<T: std::str::FromStr>() -> Vec<T> { read::<String>().split_whitespace() .map(|e| e.parse().ok().unwrap()).collect() } fn main() { let t: usize = read(); for _ in 0..t { let n: usize = read(); let a: Vec<usize> = read_vec(); let mut ans = 1; for i in 0..n { ans *= (a[i] + 1); ans %= 1_000_000_007; } if ans == 0 { ans = 1_000_000_007 - 1; } else { ans -= 1; } println!("{}", ans); } }