結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
chocobo
|
| 提出日時 | 2019-03-18 00:00:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 68 ms / 2,000 ms |
| コード長 | 921 bytes |
| コンパイル時間 | 851 ms |
| コンパイル使用メモリ | 95,556 KB |
| 実行使用メモリ | 34,952 KB |
| 最終ジャッジ日時 | 2024-07-08 07:41:14 |
| 合計ジャッジ時間 | 2,945 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
#define REP(i, n) for(ll i = 0; i < n; i++)
int main() {
int n, d;
scanf("%d %d", &n, &d);
int cnt[8000001] = {};
for(int x = 1; x <= n; x++){
for(int y = 1; y <= n; y++){
cnt[x * x + y * y]++;
}
}
int ans = 0;
for(int z = 1; z <= n; z++){
for(int w = 1; w <= n; w++){
int t = w * w - z * z + d;
if(t < 1) continue;
ans += cnt[t];
}
}
printf("%d\n", ans);
}
chocobo