結果

問題 No.800 四平方定理
ユーザー E31415926E31415926
提出日時 2019-03-17 21:36:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 961 ms / 2,000 ms
コード長 949 bytes
コンパイル時間 761 ms
コンパイル使用メモリ 95,604 KB
実行使用メモリ 65,808 KB
最終ジャッジ日時 2023-09-22 04:13:00
合計ジャッジ時間 15,087 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
5,732 KB
testcase_01 AC 17 ms
6,052 KB
testcase_02 AC 12 ms
5,760 KB
testcase_03 AC 13 ms
5,884 KB
testcase_04 AC 11 ms
5,716 KB
testcase_05 AC 13 ms
5,792 KB
testcase_06 AC 19 ms
6,100 KB
testcase_07 AC 15 ms
5,932 KB
testcase_08 AC 16 ms
6,036 KB
testcase_09 AC 16 ms
5,992 KB
testcase_10 AC 459 ms
36,060 KB
testcase_11 AC 515 ms
40,404 KB
testcase_12 AC 510 ms
40,208 KB
testcase_13 AC 470 ms
38,224 KB
testcase_14 AC 503 ms
40,132 KB
testcase_15 AC 513 ms
40,136 KB
testcase_16 AC 507 ms
40,168 KB
testcase_17 AC 511 ms
40,188 KB
testcase_18 AC 532 ms
40,148 KB
testcase_19 AC 530 ms
40,132 KB
testcase_20 AC 2 ms
5,360 KB
testcase_21 AC 2 ms
5,640 KB
testcase_22 AC 533 ms
40,312 KB
testcase_23 AC 961 ms
65,808 KB
testcase_24 AC 929 ms
65,780 KB
testcase_25 AC 953 ms
65,704 KB
testcase_26 AC 2 ms
5,328 KB
testcase_27 AC 2 ms
5,360 KB
testcase_28 AC 923 ms
65,796 KB
testcase_29 AC 940 ms
65,716 KB
testcase_30 AC 925 ms
65,708 KB
testcase_31 AC 857 ms
64,732 KB
testcase_32 AC 938 ms
65,784 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