結果
問題 | No.800 四平方定理 |
ユーザー |
|
提出日時 | 2022-12-10 01:02:52 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 196 ms / 2,000 ms |
コード長 | 689 bytes |
コンパイル時間 | 13,133 ms |
コンパイル使用メモリ | 378,652 KB |
実行使用メモリ | 102,016 KB |
最終ジャッジ日時 | 2024-10-14 23:23:42 |
合計ジャッジ時間 | 17,013 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
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); }