結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
a
|
| 提出日時 | 2019-03-17 21:46:34 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 677 bytes |
| コンパイル時間 | 1,378 ms |
| コンパイル使用メモリ | 166,216 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-07-07 21:35:59 |
| 合計ジャッジ時間 | 7,528 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 10 TLE * 2 -- * 18 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
void solve()
{
int N, D, ans = 0;
cin >> N >> D;
for (int x = 1; x <= N; x++)
{
for (int y = x; y <= N; y++)
{
int p = abs(x * x + y * y - D);
if (p == 0)
{
if (x == y) ans += N;
else ans += 2*N;
continue;
}
for (int k = 1; k * k <= p; k++)
{
if (p % k) continue;
int z = ((p / k) + k) / 2;
if ((k & 1) == ((p / k) & 1) && k != p / k && z <= N)
{
if (x == y) ans++;
else ans += 2;
//cout << x << ' ' << y << ' ' << k << ' ' << p/k << endl;
}
}
}
}
cout << ans << endl;
}
int main(void)
{
solve();
//cout << "yui(*-v・)yui" << endl;
return 0;
}
a