結果

問題 No.1273 はじめのζ関数
ユーザー StrorkisStrorkis
提出日時 2020-10-30 22:56:56
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 2,225 bytes
コンパイル時間 879 ms
コンパイル使用メモリ 148,808 KB
実行使用メモリ 10,600 KB
最終ジャッジ日時 2023-09-29 08:01:06
合計ジャッジ時間 6,175 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
6,168 KB
testcase_01 AC 37 ms
6,096 KB
testcase_02 AC 29 ms
6,104 KB
testcase_03 AC 109 ms
6,160 KB
testcase_04 AC 36 ms
6,044 KB
testcase_05 AC 39 ms
6,100 KB
testcase_06 AC 101 ms
6,144 KB
testcase_07 AC 37 ms
6,028 KB
testcase_08 AC 112 ms
6,116 KB
testcase_09 AC 23 ms
6,160 KB
testcase_10 AC 111 ms
6,108 KB
testcase_11 AC 39 ms
6,008 KB
testcase_12 AC 38 ms
6,100 KB
testcase_13 AC 113 ms
6,028 KB
testcase_14 AC 35 ms
6,080 KB
testcase_15 AC 34 ms
6,032 KB
testcase_16 AC 35 ms
6,040 KB
testcase_17 AC 36 ms
6,036 KB
testcase_18 AC 30 ms
6,144 KB
testcase_19 AC 29 ms
6,084 KB
testcase_20 WA -
testcase_21 TLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::{self, Write};
use std::{fmt, ops, str};

macro_rules! read {
    ( $t:ty ) => {{
        let mut input = String::new();
        io::stdin().read_line(&mut input).unwrap();
        input.trim_end().parse::<$t>().ok().unwrap()
    }};
    ( $( $t:ty ),* ) => {{
        let mut input = String::new();
        io::stdin().read_line(&mut input).unwrap();
        let mut iter = input.split_whitespace();
        ( $( iter.next().unwrap().parse::<$t>().unwrap() ),* )
    }};
}

struct IoStr(Vec<char>);

impl str::FromStr for IoStr {
    type Err = ();

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        Ok(IoStr(s.chars().collect()))
    }
}

impl fmt::Display for IoStr {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}", self.0.iter().collect::<String>())
    }
}

#[derive(Clone)]
struct IoVec<T>(Vec<T>);

impl<T: str::FromStr> str::FromStr for IoVec<T> {
    type Err = T::Err;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        let iter = s.split_whitespace();
        Ok(IoVec(iter.map(|x| x.parse()).collect::<Result<_, _>>()?))
    }
}

impl<T: fmt::Display> fmt::Display for IoVec<T> {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}",
            self.0.iter().map(|x| x.to_string())
                .collect::<Vec<_>>().join(" ")
        )
    }
}

impl<T> ops::Index<usize> for IoVec<T> {
    type Output = T;

    fn index(&self, i: usize) -> &Self::Output {
        self.0.get(i - 1).unwrap()
    }
}

impl<T> ops::IndexMut<usize> for IoVec<T> {
    fn index_mut(&mut self, i: usize) -> &mut Self::Output {
        self.0.get_mut(i - 1).unwrap()
    }
}

fn solve(writer: &mut io::BufWriter<io::StdoutLock>) {
    let x = read!(i32);

    let mut ans = 0.0;
    let mut v = vec![1_000_000.0; 500_000];
    for _ in 1..x {
        for j in 2..500_000 {
            v[j] /= j as f64;
        }
    }
    for _ in x..50 {
        for j in 2..500_000 {
            v[j] /= j as f64;
            ans += v[j];
        }
    }
    writeln!(writer, "{}", ans.floor() as i64).ok();
}

fn main() {
    let stdout = io::stdout();
    let mut writer = io::BufWriter::new(stdout.lock());
    solve(&mut writer);
}
0