結果

問題 No.800 四平方定理
ユーザー 里旬里旬
提出日時 2019-03-17 21:33:41
言語 C++17
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 1,331 ms / 2,000 ms
コード長 634 bytes
コンパイル時間 2,273 ms
使用メモリ 34,772 KB
最終ジャッジ日時 2023-02-11 04:38:30
合計ジャッジ時間 20,741 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 11 ms
4,900 KB
testcase_01 AC 19 ms
4,900 KB
testcase_02 AC 13 ms
4,904 KB
testcase_03 AC 15 ms
4,904 KB
testcase_04 AC 13 ms
4,900 KB
testcase_05 AC 15 ms
4,908 KB
testcase_06 AC 22 ms
4,904 KB
testcase_07 AC 15 ms
4,900 KB
testcase_08 AC 10 ms
6,952 KB
testcase_09 AC 19 ms
6,948 KB
testcase_10 AC 631 ms
18,684 KB
testcase_11 AC 680 ms
30,856 KB
testcase_12 AC 704 ms
29,540 KB
testcase_13 AC 587 ms
19,404 KB
testcase_14 AC 635 ms
29,204 KB
testcase_15 AC 711 ms
29,808 KB
testcase_16 AC 643 ms
31,228 KB
testcase_17 AC 641 ms
29,300 KB
testcase_18 AC 758 ms
30,740 KB
testcase_19 AC 763 ms
27,900 KB
testcase_20 AC 2 ms
6,952 KB
testcase_21 AC 2 ms
6,948 KB
testcase_22 AC 763 ms
28,404 KB
testcase_23 AC 1,331 ms
34,772 KB
testcase_24 AC 1,178 ms
34,472 KB
testcase_25 AC 1,331 ms
34,492 KB
testcase_26 AC 1 ms
4,904 KB
testcase_27 AC 2 ms
4,900 KB
testcase_28 AC 1,174 ms
34,396 KB
testcase_29 AC 1,268 ms
34,404 KB
testcase_30 AC 1,178 ms
34,280 KB
testcase_31 AC 1,086 ms
32,268 KB
testcase_32 AC 1,207 ms
34,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int n, d;
    cin >> n >> d;

    vector<int> xy, zw;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            xy.push_back(i*i+j*j);
            zw.push_back(i*i-j*j);
        }
    }
    sort(zw.begin(), zw.end());

    uint64_t ans = 0;
    for(auto lhs:xy){
        ans += distance(lower_bound(zw.begin(), zw.end(), lhs-d), upper_bound(zw.begin(), zw.end(), lhs-d));
    } 

    cout << ans << endl;

    return 0;
}
0