結果
問題 | No.800 四平方定理 |
ユーザー |
|
提出日時 | 2019-03-18 12:57:22 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 50 ms / 2,000 ms |
コード長 | 706 bytes |
コンパイル時間 | 1,371 ms |
コンパイル使用メモリ | 170,068 KB |
実行使用メモリ | 34,304 KB |
最終ジャッジ日時 | 2024-07-18 06:51:56 |
合計ジャッジ時間 | 2,759 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < n; i++) #define ALL(obj) obj.begin(), obj.end() const int iINF = 1e9; const long long llINF = 1e18; const int MOD = 1e9 + 7; using namespace std; int cnt[10000000]; int main() { int N, D; cin >> N >> D; map<int, int> mp; for(int x = 1; x < N + 1; x++) { for(int y = 1; y < N + 1; y++) { cnt[(int)(pow(x, 2) + pow(y, 2))] += 1; } } long long ans = 0; for(int w = 1; w < N + 1; w++) { for(int z = 1; z < N + 1; z++) { if (pow(w, 2) + D - pow(z, 2) <= 0) continue; ans += cnt[(int)(pow(w, 2) + D - pow(z, 2))]; } } cout << ans << endl; }