結果
問題 | No.1593 Perfect Distance |
ユーザー | ikd |
提出日時 | 2021-07-09 22:35:00 |
言語 | Rust (1.77.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,044 bytes |
コンパイル時間 | 1,904 ms |
コンパイル使用メモリ | 145,188 KB |
実行使用メモリ | 6,232 KB |
最終ジャッジ日時 | 2023-09-14 09:54:52 |
合計ジャッジ時間 | 8,482 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 1 ms
4,380 KB |
testcase_05 | AC | 1 ms
4,380 KB |
testcase_06 | AC | 1 ms
4,380 KB |
testcase_07 | AC | 1 ms
4,376 KB |
testcase_08 | AC | 2 ms
4,380 KB |
testcase_09 | AC | 79 ms
4,376 KB |
testcase_10 | AC | 786 ms
4,376 KB |
testcase_11 | AC | 1,986 ms
4,500 KB |
testcase_12 | TLE | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
ソースコード
//! # Bundled libraries //! //! - `procon_reader 0.1.0 (git+https://github.com/ia7ck/rust-competitive-programming#335f9833a85008436ad69ec586f94faa318557b6)` licensed under **missing** as `crate::procon_reader` use procon_reader::ProconReader; fn main() { let stdin = std::io::stdin(); let mut rd = ProconReader::new(stdin.lock()); let n: u64 = rd.get(); let mut ans: u64 = 0; for x in 1..=n { if n * n >= x * x { let y = n * n - x * x; if is_square(y) { // println!("{} {}", x, y); ans += 1; } } } println!("{}", ans); } fn is_square(y: u64) -> bool { for z in 1..=y { if z * z > y { return false; } if z * z == y { return true; } } false } // The following code was expanded by `cargo-equip`. #[cfg_attr(any(),rustfmt::skip)]#[allow(unused)]pub mod procon_reader{use std::io::BufRead;use std::str::FromStr;pub struct ProconReader<R>{r:R,l:String,i:usize,}impl<R:BufRead>ProconReader<R>{pub fn new(reader:R)->Self{Self{r:reader,l:String::new(),i:0,}}pub fn get<T>(&mut self)->T where T:FromStr,<T as FromStr>::Err:std::fmt::Debug,{self.skip_blanks();assert!(self.i<self.l.len());assert_ne!(&self.l[self.i..=self.i]," ");let rest=&self.l[self.i..];let len=rest.find(' ').unwrap_or_else(| |rest.len());let val=rest[..len].parse().unwrap_or_else(|e|panic!("{:?}, attempt to read `{}`",e,rest));self.i+=len;val}fn skip_blanks(&mut self){loop{match self.l[self.i..].find(|ch|ch!=' '){Some(j)=>{self.i+=j;break;}None=>{let mut buf=String::new();let num_bytes=self.r.read_line(&mut buf).unwrap_or_else(|_|panic!("invalid UTF-8"));assert!(num_bytes>0,"reached EOF :(");self.l=buf.trim_end_matches('\n').trim_end_matches('\r').to_string();self.i=0;}}}}pub fn get_vec<T>(&mut self,n:usize)->Vec<T>where T:FromStr,<T as FromStr>::Err:std::fmt::Debug,{(0..n).map(|_|self.get()).collect()}pub fn get_chars(&mut self)->Vec<char>{self.get::<String>().chars().collect()}}}