結果
問題 | No.732 3PrimeCounting |
ユーザー | hatoo |
提出日時 | 2018-09-28 19:51:25 |
言語 | Rust (1.77.0 + proconio) |
結果 |
AC
|
実行時間 | 557 ms / 3,000 ms |
コード長 | 3,477 bytes |
コンパイル時間 | 11,805 ms |
コンパイル使用メモリ | 403,532 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-12 05:27:33 |
合計ジャッジ時間 | 24,270 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 14 ms
6,820 KB |
testcase_01 | AC | 14 ms
6,820 KB |
testcase_02 | AC | 15 ms
6,816 KB |
testcase_03 | AC | 14 ms
6,820 KB |
testcase_04 | AC | 14 ms
6,820 KB |
testcase_05 | AC | 14 ms
6,820 KB |
testcase_06 | AC | 14 ms
6,816 KB |
testcase_07 | AC | 15 ms
6,816 KB |
testcase_08 | AC | 15 ms
6,816 KB |
testcase_09 | AC | 15 ms
6,816 KB |
testcase_10 | AC | 14 ms
6,816 KB |
testcase_11 | AC | 15 ms
6,816 KB |
testcase_12 | AC | 15 ms
6,820 KB |
testcase_13 | AC | 15 ms
6,816 KB |
testcase_14 | AC | 15 ms
6,816 KB |
testcase_15 | AC | 15 ms
6,816 KB |
testcase_16 | AC | 14 ms
6,820 KB |
testcase_17 | AC | 14 ms
6,816 KB |
testcase_18 | AC | 15 ms
6,824 KB |
testcase_19 | AC | 15 ms
6,820 KB |
testcase_20 | AC | 20 ms
6,820 KB |
testcase_21 | AC | 33 ms
6,816 KB |
testcase_22 | AC | 32 ms
6,816 KB |
testcase_23 | AC | 16 ms
6,820 KB |
testcase_24 | AC | 16 ms
6,816 KB |
testcase_25 | AC | 45 ms
6,816 KB |
testcase_26 | AC | 37 ms
6,820 KB |
testcase_27 | AC | 23 ms
6,820 KB |
testcase_28 | AC | 22 ms
6,816 KB |
testcase_29 | AC | 28 ms
6,820 KB |
testcase_30 | AC | 28 ms
6,820 KB |
testcase_31 | AC | 34 ms
6,816 KB |
testcase_32 | AC | 38 ms
6,820 KB |
testcase_33 | AC | 39 ms
6,820 KB |
testcase_34 | AC | 39 ms
6,816 KB |
testcase_35 | AC | 34 ms
6,820 KB |
testcase_36 | AC | 35 ms
6,816 KB |
testcase_37 | AC | 18 ms
6,816 KB |
testcase_38 | AC | 19 ms
6,820 KB |
testcase_39 | AC | 35 ms
6,820 KB |
testcase_40 | AC | 34 ms
6,816 KB |
testcase_41 | AC | 32 ms
6,816 KB |
testcase_42 | AC | 33 ms
6,816 KB |
testcase_43 | AC | 31 ms
6,816 KB |
testcase_44 | AC | 30 ms
6,820 KB |
testcase_45 | AC | 22 ms
6,820 KB |
testcase_46 | AC | 23 ms
6,816 KB |
testcase_47 | AC | 24 ms
6,816 KB |
testcase_48 | AC | 46 ms
6,820 KB |
testcase_49 | AC | 46 ms
6,816 KB |
testcase_50 | AC | 32 ms
6,816 KB |
testcase_51 | AC | 32 ms
6,816 KB |
testcase_52 | AC | 22 ms
6,816 KB |
testcase_53 | AC | 74 ms
6,816 KB |
testcase_54 | AC | 285 ms
6,816 KB |
testcase_55 | AC | 290 ms
6,820 KB |
testcase_56 | AC | 289 ms
6,816 KB |
testcase_57 | AC | 124 ms
6,816 KB |
testcase_58 | AC | 126 ms
6,816 KB |
testcase_59 | AC | 80 ms
6,820 KB |
testcase_60 | AC | 148 ms
6,820 KB |
testcase_61 | AC | 150 ms
6,816 KB |
testcase_62 | AC | 339 ms
6,816 KB |
testcase_63 | AC | 210 ms
6,816 KB |
testcase_64 | AC | 172 ms
6,820 KB |
testcase_65 | AC | 169 ms
6,816 KB |
testcase_66 | AC | 16 ms
6,820 KB |
testcase_67 | AC | 15 ms
6,820 KB |
testcase_68 | AC | 308 ms
6,816 KB |
testcase_69 | AC | 309 ms
6,816 KB |
testcase_70 | AC | 286 ms
6,816 KB |
testcase_71 | AC | 292 ms
6,816 KB |
testcase_72 | AC | 209 ms
6,820 KB |
testcase_73 | AC | 455 ms
6,816 KB |
testcase_74 | AC | 451 ms
6,820 KB |
testcase_75 | AC | 45 ms
6,816 KB |
testcase_76 | AC | 313 ms
6,816 KB |
testcase_77 | AC | 135 ms
6,816 KB |
testcase_78 | AC | 393 ms
6,816 KB |
testcase_79 | AC | 327 ms
6,816 KB |
testcase_80 | AC | 363 ms
6,820 KB |
testcase_81 | AC | 309 ms
6,816 KB |
testcase_82 | AC | 21 ms
6,816 KB |
testcase_83 | AC | 131 ms
6,820 KB |
testcase_84 | AC | 140 ms
6,816 KB |
testcase_85 | AC | 266 ms
6,816 KB |
testcase_86 | AC | 363 ms
6,820 KB |
testcase_87 | AC | 557 ms
6,820 KB |
testcase_88 | AC | 543 ms
6,820 KB |
ソースコード
#[doc = " https://github.com/hatoo/competitive-rust-snippets"] #[allow(unused_imports)] use std::cmp::{max, min, Ordering}; #[allow(unused_imports)] use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque}; #[allow(unused_imports)] use std::io::{stdin, stdout, BufWriter, Write}; #[allow(unused_imports)] use std::iter::FromIterator; mod util { use std::fmt::Debug; use std::io::{stdin, stdout, BufWriter, StdoutLock}; use std::str::FromStr; #[allow(dead_code)] pub fn line() -> String { let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); line.trim().to_string() } #[allow(dead_code)] pub fn chars() -> Vec<char> { line().chars().collect() } #[allow(dead_code)] pub fn gets<T: FromStr>() -> Vec<T> where <T as FromStr>::Err: Debug, { let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); line.split_whitespace() .map(|t| t.parse().unwrap()) .collect() } #[allow(dead_code)] pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) { let out = stdout(); let writer = BufWriter::new(out.lock()); f(writer) } } #[allow(unused_macros)] macro_rules ! get { ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ;; ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; ( $ t : ty ;; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ;; ) ) . collect ::< Vec < _ >> ( ) } ; } #[allow(unused_macros)] macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } } const BIG_STACK_SIZE: bool = true; #[allow(dead_code)] fn main() { use std::thread; if BIG_STACK_SIZE { thread::Builder::new() .stack_size(32 * 1024 * 1024) .name("solve".into()) .spawn(solve) .unwrap() .join() .unwrap(); } else { solve(); } } fn solve() { let mut primes = Vec::new(); for i in 2..3 * 100000 + 1 { if primes .iter() .take_while(|&&p| p * p <= i) .all(|&p| i % p != 0) { primes.push(i) } } let mut c = vec![0; 3 * 100000 + 1]; let n = get!(usize); let mut ans = 0u64; for &x in primes.iter().take_while(|&&p| p <= n) { for &p in &primes { if p >= x { ans += c[p - x]; } } for &p in &primes { if p < x { c[x + p] += 1; } } } println!("{}", ans); }