結果
問題 | No.2324 Two Countries within UEC |
ユーザー | zeronosu77108 |
提出日時 | 2023-05-28 14:11:13 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,050 bytes |
コンパイル時間 | 12,295 ms |
コンパイル使用メモリ | 400,252 KB |
実行使用メモリ | 14,848 KB |
最終ジャッジ日時 | 2024-06-08 04:52:10 |
合計ジャッジ時間 | 18,368 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 192 ms
14,336 KB |
testcase_01 | AC | 201 ms
14,720 KB |
testcase_02 | AC | 37 ms
5,376 KB |
testcase_03 | AC | 147 ms
11,520 KB |
testcase_04 | AC | 169 ms
12,928 KB |
testcase_05 | AC | 39 ms
5,376 KB |
testcase_06 | AC | 68 ms
6,272 KB |
testcase_07 | AC | 31 ms
5,376 KB |
testcase_08 | AC | 148 ms
11,392 KB |
testcase_09 | AC | 151 ms
11,776 KB |
testcase_10 | AC | 201 ms
14,720 KB |
testcase_11 | AC | 194 ms
14,592 KB |
testcase_12 | AC | 60 ms
5,632 KB |
testcase_13 | AC | 59 ms
5,888 KB |
testcase_14 | AC | 36 ms
5,376 KB |
testcase_15 | AC | 31 ms
5,376 KB |
testcase_16 | AC | 134 ms
10,496 KB |
testcase_17 | AC | 86 ms
7,296 KB |
testcase_18 | AC | 39 ms
5,376 KB |
testcase_19 | AC | 198 ms
14,720 KB |
testcase_20 | AC | 25 ms
5,376 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | AC | 204 ms
14,848 KB |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 1 ms
5,376 KB |
testcase_32 | AC | 1 ms
5,376 KB |
testcase_33 | AC | 1 ms
5,376 KB |
testcase_34 | AC | 1 ms
5,376 KB |
testcase_35 | AC | 1 ms
5,376 KB |
testcase_36 | AC | 1 ms
5,376 KB |
testcase_37 | AC | 0 ms
5,376 KB |
testcase_38 | AC | 1 ms
5,376 KB |
testcase_39 | AC | 1 ms
5,376 KB |
testcase_40 | AC | 1 ms
5,376 KB |
testcase_41 | WA | - |
testcase_42 | WA | - |
コンパイルメッセージ
warning: unused import: `std::collections::BTreeMap` --> src/main.rs:1:5 | 1 | use std::collections::BTreeMap; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: unused variable: `n` --> src/main.rs:10:9 | 10 | let n = sc.usize(); | ^ help: if this is intentional, prefix it with an underscore: `_n` | = note: `#[warn(unused_variables)]` on by default warning: variable does not need to be mutable --> src/main.rs:18:13 | 18 | let mut f = sc.usize(); | ----^ | | | help: remove this `mut` | = note: `#[warn(unused_mut)]` on by default
ソースコード
use std::collections::BTreeMap; fn main() { let mut sc = Scanner::new(); let t = 1; for _ in 0..t { solve(&mut sc); } } fn solve(sc:&mut Scanner) { let n = sc.usize(); let m = sc.usize(); let p = sc.usize(); let q = sc.usize(); for _ in 0..q { let x = sc.usize(); let mut f = sc.usize(); // x * y \= f // y = f * x^-1 // y が何個あるか let inv = pow(x % p, p-2, p); let mut y = (f * inv) % p; if y == 0 { y = p; } let ans = m/p + if m%p >= y { 1 } else { 0 }; println!("{}", ans); } } /* 1 11 2 2 1 0 1 1 */ fn pow(a:usize, x:usize, p:usize) -> usize { let mut res = 1; let mut a = a; let mut x = x; while x > 0 { if x & 1 == 1 { res = res * a % p; } a = a * a % p; x >>= 1; } res } struct Scanner { s : std::collections::VecDeque<String> } #[allow(unused)] impl Scanner { fn new() -> Self { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); Self { s : s.split_whitespace().map(|s| s.to_string()).collect() } } fn reload(&mut self) -> () { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); self.s = s.split_whitespace().map(|s| s.to_string()).collect(); } fn usize(&mut self) -> usize { self.input() } fn usize1(&mut self) -> usize { self.input::<usize>() - 1 } fn isize(&mut self) -> isize { self.input() } fn i32(&mut self) -> i32 { self.input() } fn i64(&mut self) -> i64 { self.input() } fn i128(&mut self) -> i128 { self.input() } fn u8(&mut self) -> u8 { self.input() } fn u32(&mut self) -> u32 { self.input() } fn u64(&mut self) -> u64 { self.input() } fn u128(&mut self) -> u128 { self.input() } fn edge(&mut self) -> (usize, usize) { (self.usize1(), self.usize1()) } fn edges(&mut self, m : usize) -> Vec<(usize, usize)> { let mut e = Vec::with_capacity(m); for _ in 0..m { e.push(self.edge()); } e } fn wedge<T:std::str::FromStr>(&mut self) -> (usize, usize, T) { (self.usize1(), self.usize1(), self.input()) } fn wedges<T:std::str::FromStr>(&mut self, m : usize) -> Vec<(usize, usize, T)> { let mut e = Vec::with_capacity(m); for _ in 0..m { e.push(self.wedge()); } e } fn input<T>(&mut self) -> T where T: std::str::FromStr { if self.s.is_empty() { self.reload(); } if let Some(head) = self.s.pop_front() { head.parse::<T>().ok().unwrap() } else { panic!() } } fn tuple<T, U>(&mut self) -> (T, U) where T: std::str::FromStr, U: std::str::FromStr { (self.input(), self.input()) } fn vec<T>(&mut self, n: usize) -> Vec<T> where T: std::str::FromStr { if self.s.is_empty() { self.reload(); } self.s.drain(..n).map(|s| s.parse::<T>().ok().unwrap() ).collect::<Vec<T>>() } fn nvec<T>(&mut self) -> Vec<T> where T: std::str::FromStr { let n : usize = self.input(); self.vec(n) } fn chars(&mut self) -> Vec<char> { let s : String = self.input(); s.chars().collect() } fn bytes(&mut self) -> Vec<u8> { let s : String = self.input(); s.bytes().collect() } }