結果
| 問題 | No.800 四平方定理 |
| コンテスト | |
| ユーザー |
pppppppoipoi
|
| 提出日時 | 2019-04-16 23:18:13 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 72 ms / 2,000 ms |
| コード長 | 551 bytes |
| 記録 | |
| コンパイル時間 | 565 ms |
| コンパイル使用メモリ | 69,928 KB |
| 実行使用メモリ | 65,820 KB |
| 最終ジャッジ日時 | 2024-09-22 08:24:47 |
| 合計ジャッジ時間 | 2,750 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include <iostream>
#include <vector>
using namespace std;
int main(void){
int n,d,ans = 0;
cin >> n >> d;
vector<int> a(2*2000*2000+10),b(2*2000*2000+10);
for(int x = 1;x <= n;x++){
for(int y = 1;y <= n;y++){
a[x*x+y*y]++;
}
}
for(int w = 1;w <= n;w++){
for(int z = 1;z <= n;z++){
if(w*w-z*z+d < 0 || w*w-z*z+d > 2*n*n) continue;
b[w*w-z*z+d]++;
}
}
for(int i = 1;i <= 2*n*n;i++){
ans += a[i]*b[i];
}
cout << ans << endl;
}
pppppppoipoi