結果
問題 |
No.1140 EXPotentiaLLL!
|
ユーザー |
![]() |
提出日時 | 2020-10-09 13:27:32 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,351 bytes |
コンパイル時間 | 16,457 ms |
コンパイル使用メモリ | 383,264 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-20 06:47:05 |
合計ジャッジ時間 | 22,725 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 6 WA * 6 |
コンパイルメッセージ
warning: unused variable: `i` --> src/main.rs:21:9 | 21 | for i in 0..t { | ^ help: if this is intentional, prefix it with an underscore: `_i` | = note: `#[warn(unused_variables)]` on by default warning: unused variable: `a` --> src/main.rs:23:14 | 23 | let (a, p) = (v[0], v[1]); | ^ help: if this is intentional, prefix it with an underscore: `_a`
ソースコード
#![allow(unused_imports)] use std::cmp::*; use std::collections::*; use std::io::Write; use std::ops::Bound::*; #[allow(unused_macros)] macro_rules! debug { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e, mut err) = (stringify!($e), std::io::stderr()); writeln!(err, "{} = {:?}", e, $e).unwrap() })* }; } fn main() { let t = read::<usize>(); let is_prime = get_primes(5000001); for i in 0..t { let v = read_vec::<i64>(); let (a, p) = (v[0], v[1]); if is_prime[p as usize] { println!("1"); } else { println!("-1"); } } } fn read<T: std::str::FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec<T: std::str::FromStr>() -> Vec<T> { read::<String>() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() } fn get_primes(n: i64) -> Vec<bool> { let mut is_prime = vec![true; n as usize + 1]; is_prime[0] = false; is_prime[1] = false; for i in 2..n + 1 { if is_prime[i as usize] { let mut j = 2 * i; while j < n { is_prime[j as usize] = false; j += i; } } } is_prime }