結果
| 問題 |
No.727 仲介人moko
|
| コンテスト | |
| ユーザー |
alpha_virginis
|
| 提出日時 | 2018-08-24 22:51:08 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 18 ms / 1,000 ms |
| コード長 | 2,402 bytes |
| コンパイル時間 | 12,487 ms |
| コンパイル使用メモリ | 376,936 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-23 08:36:12 |
| 合計ジャッジ時間 | 13,782 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 25 |
コンパイルメッセージ
warning: unused import: `std::ops::*` --> src/main.rs:29:5 | 29 | use std::ops::*; | ^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default
ソースコード
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::BTreeMap;
#[allow(unused_imports)]
use std::ops::*;
#[allow(unused_imports)]
use std::collections::BinaryHeap;
#[allow(unused_macros)]
macro_rules! tf {
($c:expr, $t:expr, $f:expr) => {{
if $c { $t } else { $f }
}};
}
fn main() {
let n = read_i64();
let mut res = Mod(1);
for i in 2..n+1 {
res = res * Mod(i as u64) * Mod((2*i) as u64) * Mod((2*i-1) as u64) / Mod(2);
}
println!("{}", res.0);
}
const MOD : u64 = 1_000_000_007;
#[derive(Clone,Copy,PartialEq)]
struct Mod (u64);
use std::ops::*;
impl Mod {
fn pow(self, n: u64) -> Mod {
if n == 0 {
return Mod(1);
}
let t = self.pow(n/2);
if n % 2 == 0 {
t * t
}
else {
t * t * self
}
}
}
impl Add for Mod {
type Output = Self;
fn add(self, rhs: Self) -> Self::Output {
Mod((self.0 + rhs.0) % MOD)
}
}
impl AddAssign for Mod {
fn add_assign(&mut self, rhs: Self) {
*self = *self + rhs;
}
}
impl Sub for Mod {
type Output = Self;
fn sub(self, rhs: Self) -> Self::Output {
Mod((self.0 + MOD - rhs.0 % MOD) % MOD)
}
}
impl SubAssign for Mod {
fn sub_assign(&mut self, rhs: Self) {
*self = *self - rhs;
}
}
impl Mul for Mod {
type Output = Self;
fn mul(self, rhs: Self) -> Self::Output {
Mod(self.0 % MOD * rhs.0 % MOD)
}
}
impl Div for Mod {
type Output = Self;
fn div(self, rhs: Self) -> Self::Output {
self * rhs.pow(MOD-2)
}
}
#[allow(dead_code)]
fn read_line() -> String {
let mut ret = String::new();
std::io::stdin().read_line(&mut ret).ok();
ret.pop();
return ret;
}
#[allow(dead_code)]
fn read_i64() -> i64 {
let ss = read_line();
return ss.parse::<i64>().unwrap();
}
#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
let mut res = vec![];
let ss = read_line();
for ts in ss.split_whitespace() {
let x = ts.parse::<i64>().unwrap();
res.push(x);
}
return res;
}
use std::fmt::Display;
#[allow(dead_code)]
fn write_vec<T: Display>(xs: &Vec<T>) {
if xs.len() == 0 {
println!("");
return;
}
print!("{}", xs[0]);
for i in 1..xs.len() {
print!(" {}", xs[i]);
}
println!("");
}
alpha_virginis