結果

問題 No.800 四平方定理
ユーザー 里旬里旬
提出日時 2019-03-17 21:33:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,592 ms / 2,000 ms
コード長 634 bytes
コンパイル時間 2,239 ms
コンパイル使用メモリ 204,416 KB
実行使用メモリ 35,288 KB
最終ジャッジ日時 2023-09-22 04:06:21
合計ジャッジ時間 23,354 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
4,380 KB
testcase_01 AC 20 ms
4,376 KB
testcase_02 AC 14 ms
4,376 KB
testcase_03 AC 15 ms
4,376 KB
testcase_04 AC 14 ms
4,380 KB
testcase_05 AC 16 ms
4,380 KB
testcase_06 AC 23 ms
4,380 KB
testcase_07 AC 16 ms
4,376 KB
testcase_08 AC 11 ms
4,376 KB
testcase_09 AC 21 ms
4,380 KB
testcase_10 AC 693 ms
18,908 KB
testcase_11 AC 741 ms
29,888 KB
testcase_12 AC 783 ms
30,260 KB
testcase_13 AC 650 ms
19,292 KB
testcase_14 AC 682 ms
30,716 KB
testcase_15 AC 781 ms
28,652 KB
testcase_16 AC 705 ms
28,680 KB
testcase_17 AC 699 ms
27,992 KB
testcase_18 AC 872 ms
28,592 KB
testcase_19 AC 866 ms
28,000 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 870 ms
28,060 KB
testcase_23 AC 1,592 ms
35,116 KB
testcase_24 AC 1,344 ms
34,460 KB
testcase_25 AC 1,548 ms
35,288 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1,334 ms
34,272 KB
testcase_29 AC 1,459 ms
34,804 KB
testcase_30 AC 1,337 ms
34,312 KB
testcase_31 AC 1,215 ms
32,696 KB
testcase_32 AC 1,384 ms
34,892 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