結果
| 問題 | No.800 四平方定理 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-03-17 21:26:50 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 417 bytes |
| 記録 | |
| コンパイル時間 | 1,913 ms |
| コンパイル使用メモリ | 218,644 KB |
| 実行使用メモリ | 91,904 KB |
| 最終ジャッジ日時 | 2026-06-07 07:48:27 |
| 合計ジャッジ時間 | 10,266 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 10 TLE * 2 -- * 18 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
int N, D;
cin >> N >> D;
map<int, int> mp1, mp2;
for(int i=1; i<=N; i++) for(int j=1; j<=N; j++){
mp1[i*i+j*j]++;
mp2[i*i-j*j]++;
}
int64_t ans = 0;
for(auto& p : mp2){
int X = p.first;
int Y = D-X;
if(mp1.count(Y)) ans += p.second * mp1[Y];
}
cout << ans << endl;
return 0;
}