結果

問題 No.781 円周上の格子点の数え上げ
ユーザー ducktailducktail
提出日時 2019-08-02 14:32:09
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 203 ms / 2,000 ms
コード長 648 bytes
コンパイル時間 18,107 ms
コンパイル使用メモリ 376,636 KB
実行使用メモリ 80,000 KB
最終ジャッジ日時 2024-07-05 08:06:59
合計ジャッジ時間 18,063 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main(){
  let xy: Vec<usize> = read_vec();
  let x = xy[0];
  let y = xy[1];

  let mut i: usize = 1;
  let mut j: usize = 0;
  let mut v: Vec<usize> = vec![0; y+1];

  while i * i <= y {
    while j * j <= y {
      let ix = i * i + j * j;
      if x <= ix && ix <= y {
        v[ix] += 4;
      }
      j += 1;
    }
    i += 1;
    j = 0;
  }

  println!("{}", v.iter().max().unwrap());
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}
0