結果
問題 | No.800 四平方定理 |
ユーザー |
![]() |
提出日時 | 2019-03-17 22:06:40 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 58 ms / 2,000 ms |
コード長 | 508 bytes |
コンパイル時間 | 1,635 ms |
コンパイル使用メモリ | 168,080 KB |
実行使用メモリ | 34,524 KB |
最終ジャッジ日時 | 2024-07-07 23:13:14 |
合計ジャッジ時間 | 3,359 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include "bits/stdc++.h" using namespace std; void solve() { int N, D, ans = 0; cin >> N >> D; vector<int> mp(N*N*2+1); for (int y = 1; y <= N; y++) { for (int z = 1; z <= N; z++) { int s = y*y+z*z; if (s<=N*N*2) mp[s]++; } } for (int x = 1; x <= N; x++) { for (int w = 1; w <= N; w++) { int p = D + w * w - x * x; if (p > N*N*2 || p < 0) continue; ans += mp[p]; } } cout << ans << endl; } int main(void) { solve(); //cout << "yui(*-v・)yui" << endl; return 0; }