結果

問題 No.800 四平方定理
ユーザー jdoiejdoie
提出日時 2019-03-17 23:09:05
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,729 bytes
コンパイル時間 1,424 ms
コンパイル使用メモリ 151,092 KB
実行使用メモリ 21,532 KB
最終ジャッジ日時 2023-09-22 09:57:34
合計ジャッジ時間 18,344 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
4,376 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

//
//#define _GLIBCXX_DEBUG
//#define NDEBUG
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const ll linf = 1e18;
const int inf = 1e9;

#define vl vector<ll>
#define pg priority_queue<ll, vector<ll>, greater<ll>>
#define pq priority_queue<ll>
#define rp(i, a, n) for (int i = a; i < n; i++)
#define pr(i, a, n) for (int i = a; i >= n; i--)
#define fm(i, mp) for (auto i = (mp).begin(); i != (mp).end(); ++i)
#define al(v) (v).begin(), (v).end()
#define mz(x) memset(x, 0, sizeof(x))
#define mi(x) memset(x, 0x3F, sizeof(x))
#define ce(x) cout << (x) << endl
#define cs(x) cout << (x) << ' '
#define co(x) cout << (x)
#define cd(x, y) cout << setprecision(x) << (y) << endl
#define ma make_pair
#define pb push_back
#define fs first
#define sc second
#define ceo cout << endl
#define cso cout << ' '
clock_t startT, endT;
int time()
{
    endT = clock();
    cerr << (endT - startT) / 1000 << "ms" << endl;
    return (endT - startT) / 1000;
}

int main()
{
    startT = clock();
    cin.tie(0);
    ios::sync_with_stdio(0);
    //----------------------------
    ll n, d;
    cin >> n >> d;
    vl wz;
    rp(i, 1, n + 1)
    {
        rp(j, 1, n + 1)
        {
            if (i - j >= 0)
                wz.pb((i + j) * (i - j));
        }
    }
    sort(al(wz));
  //  rp(i, 0, wz.size()) cs(wz[i]);

    ll ans = 0;
    rp(i, 0, n + 1)
    {
        rp(j, 1, n + 1)
        {
            ll k = i * i + j * j - d;
            ll k2 = lower_bound(al(wz), k) - wz.begin();
            ll k3 = upper_bound(al(wz), k) - wz.begin();
            //    cs(k2);
            //  ce(k3);
            ans += k3 - k2;
        }
    }
    ce(ans);

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

    time();
    return 0;
}
//
0