結果

問題 No.800 四平方定理
ユーザー dsaito11dsaito11
提出日時 2019-07-03 19:44:55
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,593 ms / 2,000 ms
コード長 873 bytes
コンパイル時間 1,072 ms
コンパイル使用メモリ 90,712 KB
実行使用メモリ 85,584 KB
最終ジャッジ日時 2023-10-14 09:58:17
合計ジャッジ時間 22,495 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
4,352 KB
testcase_01 AC 18 ms
4,436 KB
testcase_02 AC 13 ms
4,348 KB
testcase_03 AC 15 ms
4,352 KB
testcase_04 AC 14 ms
4,348 KB
testcase_05 AC 16 ms
4,352 KB
testcase_06 AC 21 ms
4,704 KB
testcase_07 AC 18 ms
4,476 KB
testcase_08 AC 13 ms
4,480 KB
testcase_09 AC 19 ms
4,540 KB
testcase_10 AC 715 ms
37,264 KB
testcase_11 AC 751 ms
47,356 KB
testcase_12 AC 797 ms
49,644 KB
testcase_13 AC 607 ms
35,508 KB
testcase_14 AC 660 ms
52,116 KB
testcase_15 AC 800 ms
52,928 KB
testcase_16 AC 667 ms
52,240 KB
testcase_17 AC 673 ms
52,008 KB
testcase_18 AC 903 ms
51,048 KB
testcase_19 AC 891 ms
50,988 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 896 ms
50,540 KB
testcase_23 AC 1,589 ms
62,164 KB
testcase_24 AC 1,277 ms
67,424 KB
testcase_25 AC 1,593 ms
63,288 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,352 KB
testcase_28 AC 1,255 ms
66,584 KB
testcase_29 AC 1,415 ms
81,468 KB
testcase_30 AC 1,250 ms
66,240 KB
testcase_31 AC 1,154 ms
64,148 KB
testcase_32 AC 1,344 ms
85,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//#include <bits/stdc++.h>

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>


#define INF 10e15
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;


int main() {
    long long int n, d;
    cin >> n >> d;

    vector<long long int> x, y;

    long long int i, j;
    for(i = 1; i <= n; i++){
        for(j = 1; j <= n; j++){
            x.push_back(i*i + j*j);
            
            if(i*i - j*j + d >= 0){
                y.push_back(i*i - j*j + d);
            }
        }
    }

    sort(y.begin(), y.end());

    long long int count = 0;
    for(i = 0; i < x.size(); i++){
        count += upper_bound(y.begin(), y.end(), x[i]) - lower_bound(y.begin(), y.end(), x[i]);
    }

    cout << count << endl;
}


0