結果

問題 No.781 円周上の格子点の数え上げ
ユーザー cympfhcympfh
提出日時 2019-01-15 16:57:11
言語 Rust
(1.77.0)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 1,567 bytes
コンパイル時間 1,220 ms
コンパイル使用メモリ 146,864 KB
実行使用メモリ 40,780 KB
最終ジャッジ日時 2023-09-07 11:42:26
合計ジャッジ時間 2,931 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
4,384 KB
testcase_01 AC 9 ms
4,384 KB
testcase_02 AC 10 ms
4,384 KB
testcase_03 AC 9 ms
4,380 KB
testcase_04 AC 9 ms
4,380 KB
testcase_05 AC 9 ms
4,384 KB
testcase_06 AC 10 ms
4,380 KB
testcase_07 AC 9 ms
4,380 KB
testcase_08 AC 18 ms
4,380 KB
testcase_09 AC 18 ms
4,380 KB
testcase_10 AC 10 ms
4,384 KB
testcase_11 AC 10 ms
4,380 KB
testcase_12 AC 72 ms
23,972 KB
testcase_13 AC 123 ms
40,780 KB
testcase_14 AC 11 ms
4,380 KB
testcase_15 AC 10 ms
4,384 KB
testcase_16 AC 10 ms
4,380 KB
testcase_17 AC 66 ms
25,268 KB
testcase_18 AC 15 ms
4,384 KB
testcase_19 AC 15 ms
4,384 KB
testcase_20 AC 15 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{ min, max };

macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

fn main() {
    let mut sc = Scanner::new();
    let r0: u64 = sc.cin();
    let r1: u64 = sc.cin();
    let mut counts = vec![0; 10000002];
    for x in 0.. {
        if x * x > r1 { break }
        for y in 1.. {
            if y * y > r1 { break }
            let r = x*x+y*y;
            if r0 <= r && r <= r1 {
                counts[r as usize] += 1;
            }
        }
    }
    // for i in 1..30 { trace!(i, counts[i]); }
    put!(4 * counts.iter().max().unwrap());
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}
0