結果
| 問題 | No.800 四平方定理 |
| コンテスト | |
| ユーザー |
pppppppoipoi
|
| 提出日時 | 2019-04-16 23:18:13 |
| 言語 | C++14 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 48 ms / 2,000 ms |
| + 939µs | |
| コード長 | 551 bytes |
| 記録 | |
| コンパイル時間 | 325 ms |
| コンパイル使用メモリ | 79,440 KB |
| 実行使用メモリ | 65,992 KB |
| 最終ジャッジ日時 | 2026-09-02 08:16:54 |
| 合計ジャッジ時間 | 2,989 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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