結果

問題 No.800 四平方定理
ユーザー phsplsphspls
提出日時 2022-12-10 01:02:52
言語 Rust
(1.77.0)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 689 bytes
コンパイル時間 620 ms
コンパイル使用メモリ 164,232 KB
実行使用メモリ 102,016 KB
最終ジャッジ日時 2024-04-22 23:32:36
合計ジャッジ時間 2,946 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
5,248 KB
testcase_01 AC 12 ms
5,376 KB
testcase_02 AC 11 ms
5,376 KB
testcase_03 AC 10 ms
5,376 KB
testcase_04 AC 12 ms
5,376 KB
testcase_05 AC 11 ms
5,376 KB
testcase_06 AC 12 ms
5,376 KB
testcase_07 AC 11 ms
5,376 KB
testcase_08 AC 12 ms
5,376 KB
testcase_09 AC 11 ms
5,376 KB
testcase_10 AC 40 ms
51,200 KB
testcase_11 AC 43 ms
54,912 KB
testcase_12 AC 43 ms
56,576 KB
testcase_13 AC 38 ms
49,792 KB
testcase_14 AC 40 ms
53,120 KB
testcase_15 AC 42 ms
56,832 KB
testcase_16 AC 40 ms
53,760 KB
testcase_17 AC 40 ms
53,760 KB
testcase_18 AC 45 ms
61,312 KB
testcase_19 AC 48 ms
61,312 KB
testcase_20 AC 11 ms
5,376 KB
testcase_21 AC 11 ms
5,376 KB
testcase_22 AC 63 ms
61,568 KB
testcase_23 AC 94 ms
102,016 KB
testcase_24 AC 87 ms
94,208 KB
testcase_25 AC 95 ms
101,760 KB
testcase_26 AC 10 ms
5,376 KB
testcase_27 AC 11 ms
5,376 KB
testcase_28 AC 91 ms
93,696 KB
testcase_29 AC 88 ms
98,008 KB
testcase_30 AC 86 ms
93,824 KB
testcase_31 AC 80 ms
87,296 KB
testcase_32 AC 93 ms
95,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

    let mut cnts = vec![0usize; 2*2000*2000+1];
    let mut cnt2 = vec![0usize; 2*2000*2000+1];
    for x in 1..=n {
        for y in 1..=n {
            cnts[x*x + y*y] += 1;
        }
    }
    for z in 1..=n {
        for w in 1..=n {
            if z*z > w*w + d { continue; }
            cnt2[w*w +d - z*z] += 1;
        }
    }
    let mut result = 0usize;
    for i in 0..=2*2000*2000 {
        result += cnts[i] * cnt2[i];
    }
    println!("{}", result);
}
0