結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
noisy_noimin
|
| 提出日時 | 2019-03-18 00:01:15 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,126 bytes |
| コンパイル時間 | 917 ms |
| コンパイル使用メモリ | 103,476 KB |
| 実行使用メモリ | 149,760 KB |
| 最終ジャッジ日時 | 2024-07-08 07:41:39 |
| 合計ジャッジ時間 | 4,903 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 10 TLE * 6 -- * 14 |
ソースコード
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
{ 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};
int main() {
ll n, d;
cin >> n >> d;
map<ll, ll> cnt1, cnt2;
for(int i=1;i<=n;++i) {
for(int j=1;j<=n;++j) {
++cnt1[i*i+j*j];
++cnt2[i*i-j*j];
}
}
ll ans = 0LL;
for(auto itr=cnt1.begin();itr!=cnt1.end();++itr) {
ans += ((itr->second) * cnt2[d-(itr->first)]) % MOD;
ans %= MOD;
// cerr << i << ": " << cnt1[i] << " " << d-i << ": " << cnt2[d-i+n*n] << endl;
}
cout << ans << endl;
}
noisy_noimin