結果

問題 No.781 円周上の格子点の数え上げ
ユーザー phsplsphspls
提出日時 2022-12-08 23:49:07
言語 Rust
(1.77.0)
結果
AC  
実行時間 139 ms / 2,000 ms
コード長 738 bytes
コンパイル時間 1,549 ms
コンパイル使用メモリ 148,788 KB
実行使用メモリ 80,016 KB
最終ジャッジ日時 2023-08-04 20:27:50
合計ジャッジ時間 3,363 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 122 ms
79,972 KB
testcase_09 AC 131 ms
79,928 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 131 ms
80,016 KB
testcase_13 AC 139 ms
79,948 KB
testcase_14 AC 5 ms
6,312 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 74 ms
48,120 KB
testcase_18 AC 67 ms
48,244 KB
testcase_19 AC 69 ms
49,620 KB
testcase_20 AC 69 ms
49,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

    let mut result = vec![0usize; y+1];
    for i in 0.. {
        let val = i * i;
        if val > y { break; }
        for j in 0.. {
            if i == 0 && j == 0 { continue; }
            let val2 = j * j;
            let idx = val + val2;
            if idx > y { break; }
            if val == 0 || val2 == 0 {
                result[idx] += 2;
            } else {
                result[idx] += 4;
            }
        }
    }
    println!("{}", (x..=y).map(|i| result[i]).max().unwrap());
}
0