結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
ama_nuko
|
| 提出日時 | 2019-03-18 00:55:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,478 bytes |
| コンパイル時間 | 973 ms |
| コンパイル使用メモリ | 99,116 KB |
| 実行使用メモリ | 65,900 KB |
| 最終ジャッジ日時 | 2024-07-08 07:52:38 |
| 合計ジャッジ時間 | 3,358 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 WA * 2 RE * 1 |
ソースコード
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>
#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
using namespace std;
typedef pair<int, int> P;
const int INF = 1e15;
const int MOD = 1e9+7;
template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
return vector2<T>(n0, vector<T>(n1, e));
}
template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n, d;
cin >> n >> d;
vector<int> a(2 * n * n + 1);
for(int x = 1; x <= n; x++){
for(int y = 1; y <= n; y++){
a[x*x+y*y]++;
}
}
int ans = 0;
for(int x = 1; x <= n; x++){
for(int y = 1; y <= n; y++){
int tmp = x * x + d - y * y;
if(tmp < 0){
continue;
}
ans += a[tmp];
}
}
cout << ans << endl;
return 0;
}
ama_nuko