結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
dsm4up2c
|
| 提出日時 | 2019-03-18 00:47:03 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 166 ms / 2,000 ms |
| コード長 | 764 bytes |
| コンパイル時間 | 530 ms |
| コンパイル使用メモリ | 74,068 KB |
| 実行使用メモリ | 128,244 KB |
| 最終ジャッジ日時 | 2024-07-08 07:49:59 |
| 合計ジャッジ時間 | 3,644 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(),x.end()
const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;
int main()
{
ll n,d;
cin>>n>>d;
vector<ll> cnt_xy(2*n*n+1,0),cnt_wz(2*n*n+1,0);
for(ll x = 1; x <= n; x++){
for(ll y = 1; y <= n; y++){
ll res = x*x + y*y;
cnt_xy[res]++;
}
}
for(ll w = 1; w <= n; w++){
for(ll z = 1; z <= n; z++){
ll res = w*w-z*z+d;
if(res>=1 && res <= 2*n*n) cnt_wz[res]++;
}
}
ll ans=0;
for(int i = 1; i <= 2*n*n; i++){
ans += cnt_xy[i]*cnt_wz[i];
}
cout << ans << endl;
return 0;
}
dsm4up2c