結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-03-17 21:31:31 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 96 ms / 2,000 ms |
| コード長 | 475 bytes |
| コンパイル時間 | 1,714 ms |
| コンパイル使用メモリ | 191,900 KB |
| 最終ジャッジ日時 | 2025-01-06 22:45:34 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
int N, D;
cin >> N >> D;
const int M = 2000*2000*2+1;
int offset = 2000*2000;
static int mp1[M], mp2[M];
for(int i=1; i<=N; i++) for(int j=1; j<=N; j++){
mp1[i*i+j*j]++;
mp2[i*i-j*j+offset]++;
}
int64_t ans = 0;
for(int i=0; i<M; i++){
int Y = D - i + offset;
if(0<=Y && Y<M) ans += mp1[i] * mp2[Y];
}
cout << ans << endl;
return 0;
}