結果

問題 No.781 円周上の格子点の数え上げ
ユーザー phsplsphspls
提出日時 2020-07-06 23:01:24
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 769 bytes
コンパイル時間 672 ms
コンパイル使用メモリ 171,600 KB
実行使用メモリ 79,996 KB
最終ジャッジ日時 2023-10-25 00:10:48
合計ジャッジ時間 1,936 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 5 ms
4,348 KB
testcase_09 AC 5 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 62 ms
45,696 KB
testcase_13 AC 106 ms
79,996 KB
testcase_14 AC 3 ms
4,752 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 62 ms
48,252 KB
testcase_18 AC 4 ms
4,348 KB
testcase_19 AC 4 ms
4,348 KB
testcase_20 AC 4 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::cmp::max;

fn main() {
    let mut xy = String::new();
    std::io::stdin().read_line(&mut xy).ok();
    let xy: Vec<usize> = xy.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let x = xy[0];
    let y = xy[1];

    let mut result: Vec<usize> = vec![0; y+1];
    for i in 0..y {
        let a: usize = i * i;
        if a > y { break; }
        for j in i..y {
            let b: usize = j * j;
            if a + b > y { break; }
            if a + b < x { continue; }
            if a == 0 || i == j {
                result[a+b] += 4;
            } else {
                result[a+b] += 8;
            }
        }
    }
    let mut val: usize = 0;
    for i in x..=y {
        val = max(val, result[i]);
    }
    println!("{}", val);
}
0