結果

問題 No.800 四平方定理
ユーザー siro53siro53
提出日時 2019-09-30 02:31:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,225 bytes
コンパイル時間 1,619 ms
コンパイル使用メモリ 165,628 KB
実行使用メモリ 42,428 KB
最終ジャッジ日時 2024-04-14 07:41:39
合計ジャッジ時間 6,424 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
42,272 KB
testcase_01 AC 19 ms
42,296 KB
testcase_02 AC 19 ms
42,140 KB
testcase_03 AC 19 ms
42,288 KB
testcase_04 AC 19 ms
42,312 KB
testcase_05 AC 20 ms
42,248 KB
testcase_06 AC 19 ms
42,416 KB
testcase_07 AC 20 ms
42,228 KB
testcase_08 AC 20 ms
42,140 KB
testcase_09 AC 20 ms
42,276 KB
testcase_10 AC 50 ms
42,316 KB
testcase_11 AC 50 ms
42,428 KB
testcase_12 AC 57 ms
42,284 KB
testcase_13 AC 40 ms
42,344 KB
testcase_14 AC 50 ms
42,236 KB
testcase_15 AC 52 ms
42,304 KB
testcase_16 AC 51 ms
42,252 KB
testcase_17 AC 47 ms
42,276 KB
testcase_18 AC 70 ms
42,284 KB
testcase_19 AC 60 ms
42,252 KB
testcase_20 AC 19 ms
42,248 KB
testcase_21 AC 19 ms
42,312 KB
testcase_22 AC 66 ms
42,200 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 20 ms
42,280 KB
testcase_27 AC 18 ms
42,208 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

vector<int> hoge(5000001);
vector<int> huga(5000001);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, d;
    cin >> n >> d;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            hoge[i * i + j * j]++;
            int tmp = i * i - j * j + d;
            if (tmp >= 2 && tmp <= 2 * n * n)
            {
                huga[tmp]++;
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i < 5000001; i++)
    {
        ans += (ll)hoge[i] * huga[i];
    }
    cout << ans << endl;
}
0