結果
| 問題 | No.73 helloworld |
| コンテスト | |
| ユーザー |
aimy
|
| 提出日時 | 2017-11-24 22:04:44 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,671 bytes |
| コンパイル時間 | 23,941 ms |
| コンパイル使用メモリ | 400,632 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-27 07:12:30 |
| 合計ジャッジ時間 | 24,913 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 WA * 8 RE * 2 |
コンパイルメッセージ
warning: use of deprecated method `core::str::<impl str>::trim_right`: superseded by `trim_end`
--> src/main.rs:77:9
|
77 | buf.trim_right().parse::<T>().ok().unwrap()
| ^^^^^^^^^^
|
= note: `#[warn(deprecated)]` on by default
help: replace the use of the deprecated method
|
77 | buf.trim_end().parse::<T>().ok().unwrap()
| ~~~~~~~~
warning: use of deprecated method `core::str::<impl str>::trim_right`: superseded by `trim_end`
--> src/main.rs:92:22
|
92 | let mut it = buf.trim_right().split_whitespace();
| ^^^^^^^^^^
|
help: replace the use of the deprecated method
|
92 | let mut it = buf.trim_end().split_whitespace();
| ~~~~~~~~
warning: use of deprecated method `core::str::<impl str>::trim_right`: superseded by `trim_end`
--> src/main.rs:110:22
|
110 | let mut it = buf.trim_right().split_whitespace();
| ^^^^^^^^^^
|
help: replace the use of the deprecated method
|
110 | let mut it = buf.trim_end().split_whitespace();
| ~~~~~~~~
warning: use of deprecated method `core::str::<impl str>::trim_right`: superseded by `trim_end`
--> src/main.rs:129:9
|
129 | buf.trim_right().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
| ^^^^^^^^^^
|
help: replace the use of the deprecated method
|
129 | buf.trim_end().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
| ~~~~~~~~
warning: use of deprecated method `core::str::<impl str>::trim_right`: superseded by `trim_end`
--> src/main.rs:144:9
|
144 | buf.trim_right().chars().collect()
| ^^^^^^^^^^
|
help: replace the use of the deprecated method
|
144 | buf.trim_end().chars().collect()
| ~~~~~~~~
ソースコード
fn main() {
let alphas = get::vals::<u64>(26);
let ord = |c| c as usize - 'a' as usize;
let d = Combination::new(alphas[ord('d')]).comb(1);
let e = Combination::new(alphas[ord('e')]).comb(1);
let h = Combination::new(alphas[ord('h')]).comb(1);
let l = Combination::new(alphas[ord('l')]-1).comb(3-1);
let o = Combination::new(alphas[ord('o')]-1).comb(2-1);
let r = Combination::new(alphas[ord('r')]).comb(1);
let w = Combination::new(alphas[ord('w')]).comb(1);
println!("{}", d*e*h*l*o*e*r*w)
}
struct Combination {
n: u64,
fact_table: Vec<u64>
}
#[allow(dead_code)]
impl Combination {
fn new(n: u64) -> Combination {
Combination {
n: n,
fact_table: (1..n+1).scan(1,|a,x|{*a=modulo::mul(*a,x); Some(*a)}).collect::<Vec<_>>()
}
}
fn comb(&self, r: u64) -> u64 {
match r {
_ if self.n < r => 0,
_ if self.n == r => 1,
_ => {
let a = self.fact_table[self.n as usize - 1];
let b = modulo::pow(self.fact_table[r as usize - 1], modulo::MOD-2);
let c = modulo::pow(self.fact_table[(self.n - r) as usize - 1], modulo::MOD-2);
[a,b,c].iter().fold(1, |a,&x| modulo::mul(a,x))
}
}
}
}
#[allow(dead_code)]
mod modulo {
pub const MOD: u64 = 1_000_000_007;
pub fn plus(x: u64, y: u64) -> u64 {
(x + y) % MOD
}
pub fn mul(x: u64, y: u64) -> u64 {
(x * y) % MOD
}
pub fn pow(x: u64, n: u64) -> u64 {
match n {
0 => 1,
_ if n % 2 == 1 => mul(x, pow(x, n-1)),
_ => {
let q = pow(x, n>>1);
mul(q, q)
}
}
}
}
#[allow(dead_code)]
mod get {
use std::io::*;
use std::str::*;
pub fn val<T: FromStr>() -> T {
let mut buf = String::new();
let s = stdin();
s.lock().read_line(&mut buf).ok();
buf.trim_right().parse::<T>().ok().unwrap()
}
pub fn vals<T: FromStr>(n: usize) -> Vec<T> {
let mut vec: Vec<T> = vec![];
for _ in 0 .. n {
vec.push(val());
}
vec
}
pub fn tuple<T1: FromStr, T2: FromStr>() -> (T1, T2) {
let mut buf = String::new();
let s = stdin();
s.lock().read_line(&mut buf).ok();
let mut it = buf.trim_right().split_whitespace();
let x = it.next().unwrap().parse::<T1>().ok().unwrap();
let y = it.next().unwrap().parse::<T2>().ok().unwrap();
(x, y)
}
pub fn tuples<T1: FromStr, T2: FromStr>(n: usize) -> Vec<(T1, T2)> {
let mut vec: Vec<(T1, T2)> = vec![];
for _ in 0 .. n {
vec.push(tuple());
}
vec
}
pub fn tuple3<T1: FromStr, T2: FromStr, T3: FromStr>() -> (T1, T2, T3) {
let mut buf = String::new();
let s = stdin();
s.lock().read_line(&mut buf).ok();
let mut it = buf.trim_right().split_whitespace();
let x = it.next().unwrap().parse::<T1>().ok().unwrap();
let y = it.next().unwrap().parse::<T2>().ok().unwrap();
let z = it.next().unwrap().parse::<T3>().ok().unwrap();
(x, y, z)
}
pub fn tuple3s<T1: FromStr, T2: FromStr, T3: FromStr>(n: usize) -> Vec<(T1, T2, T3)> {
let mut vec: Vec<(T1, T2, T3)> = vec![];
for _ in 0 .. n {
vec.push(tuple3());
}
vec
}
pub fn list<T: FromStr>() -> Vec<T> {
let mut buf = String::new();
let s = stdin();
s.lock().read_line(&mut buf).ok();
buf.trim_right().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
}
pub fn lists<T: FromStr>(h: usize) -> Vec<Vec<T>> {
let mut mat: Vec<Vec<T>> = vec![];
for _ in 0 .. h {
mat.push(list());
}
mat
}
pub fn chars() -> Vec<char> {
let mut buf = String::new();
let s = stdin();
s.lock().read_line(&mut buf).ok();
buf.trim_right().chars().collect()
}
}
aimy