結果
問題 | No.144 エラトステネスのざる |
ユーザー |
|
提出日時 | 2024-09-18 09:35:46 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 46 ms / 2,000 ms |
コード長 | 736 bytes |
コンパイル時間 | 13,351 ms |
コンパイル使用メモリ | 379,024 KB |
実行使用メモリ | 5,888 KB |
最終ジャッジ日時 | 2024-09-18 09:36:01 |
合計ジャッジ時間 | 14,643 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
use std::io;use std::io::prelude::*;fn main() -> () {let stdin = io::read_to_string(io::stdin()).unwrap();let mut stdin = stdin.split_ascii_whitespace();let stdout = io::stdout();let mut stdout = io::BufWriter::new(stdout.lock());let n: usize = stdin.next().unwrap().parse::<usize>().unwrap();let p: f64 = stdin.next().unwrap().parse::<f64>().unwrap();let mut d = vec![0; n + 1];for i in 2..=n {let mut j = 2 * i;while j <= n {d[j] += 1;j += i;}}let res = (|| {let mut e = 0.0;for i in 2..=n {e += (1.0 - p).powi(d[i]);}e})();writeln!(stdout, "{}", res).unwrap_or(());}