結果
問題 |
No.3133 法B逆元
|
ユーザー |
|
提出日時 | 2025-06-05 23:59:15 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 37 ms / 2,000 ms |
コード長 | 1,468 bytes |
コンパイル時間 | 12,978 ms |
コンパイル使用メモリ | 393,980 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-06-05 23:59:31 |
合計ジャッジ時間 | 14,667 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
コンパイルメッセージ
warning: method `read_vec` is never used --> src/main.rs:8:8 | 4 | trait ReadExt { | ------- method in this trait ... 8 | fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> | ^^^^^^^^ | = note: `#[warn(dead_code)]` on by default
ソースコード
use std::str::{FromStr, SplitWhitespace}; use std::fmt::Debug; trait ReadExt { fn read<T: FromStr>(&mut self) -> T where <T as FromStr>::Err: Debug; fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> where <T as FromStr>::Err: Debug, T: Debug; } impl<'a> ReadExt for SplitWhitespace<'a> { fn read<T: FromStr>(&mut self) -> T where <T as FromStr>::Err: Debug, { if let Some(word) = self.next() { match word.parse::<T>() { Ok(res) => { res } Err(e) => { panic!("Failed to parse '{}' as requested type: {:?}", word, e); } } } else { panic!("Failed to read: No more words available for parsing."); } } fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> where <T as FromStr>::Err: Debug, T: Debug, { let mut vec = Vec::with_capacity(n); for _ in 0..n { let element = self.read::<T>(); vec.push(element); } vec } } fn main() { let stdin = std::io::read_to_string(std::io::stdin()).unwrap(); let mut stdin = stdin.split_whitespace(); let n = stdin.read::<u128>(); let b = stdin.read::<u128>(); for i in 0..b{ if (n*i)%b == 1 % b { println!("{:?}",i); return; } } println!("NaN"); }