結果

問題 No.800 四平方定理
ユーザー E31415926E31415926
提出日時 2019-03-17 21:36:10
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 900 ms / 2,000 ms
コード長 949 bytes
コンパイル時間 1,443 ms
使用メモリ 65,976 KB
最終ジャッジ日時 2023-02-11 04:47:57
合計ジャッジ時間 15,072 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 9 ms
5,796 KB
testcase_01 AC 15 ms
6,952 KB
testcase_02 AC 11 ms
5,824 KB
testcase_03 AC 12 ms
5,980 KB
testcase_04 AC 10 ms
6,948 KB
testcase_05 AC 12 ms
5,912 KB
testcase_06 AC 18 ms
6,212 KB
testcase_07 AC 14 ms
6,100 KB
testcase_08 AC 15 ms
6,228 KB
testcase_09 AC 15 ms
6,096 KB
testcase_10 AC 425 ms
34,408 KB
testcase_11 AC 476 ms
38,788 KB
testcase_12 AC 472 ms
37,620 KB
testcase_13 AC 434 ms
35,844 KB
testcase_14 AC 468 ms
38,284 KB
testcase_15 AC 476 ms
38,520 KB
testcase_16 AC 473 ms
38,632 KB
testcase_17 AC 476 ms
39,128 KB
testcase_18 AC 489 ms
38,996 KB
testcase_19 AC 490 ms
38,424 KB
testcase_20 AC 2 ms
5,524 KB
testcase_21 AC 1 ms
6,952 KB
testcase_22 AC 494 ms
38,668 KB
testcase_23 AC 900 ms
65,976 KB
testcase_24 AC 879 ms
65,936 KB
testcase_25 AC 897 ms
65,828 KB
testcase_26 AC 2 ms
6,948 KB
testcase_27 AC 1 ms
5,412 KB
testcase_28 AC 873 ms
65,668 KB
testcase_29 AC 888 ms
65,948 KB
testcase_30 AC 875 ms
65,900 KB
testcase_31 AC 810 ms
61,916 KB
testcase_32 AC 887 ms
65,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<complex>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int xy[2000 * 2000];
int zw[2000 * 2000];

signed main() {
    int n, d;
    cin >> n >> d;
    for (int x = 1; x <= n; ++x) {
        for (int y = 1; y <= n; ++y) {
            xy[(x - 1) * n + (y - 1)] = x * x + y * y;
            zw[(x - 1) * n + (y - 1)] = x * x - y * y;
        }
    }
    sort(xy, xy + n * n);
    sort(zw, zw + n * n);
    int ans = 0;
    rep(i, n * n) {
        ans += u_b(zw, zw + n * n, d - xy[i]) - l_b(zw, zw + n * n, d - xy[i]);
    }
    cout << ans << endl;
    return 0;
}
0