結果

問題 No.800 四平方定理
ユーザー face4face4
提出日時 2019-03-17 22:02:59
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 513 bytes
コンパイル時間 479 ms
使用メモリ 65,544 KB
最終ジャッジ日時 2023-02-11 07:04:30
合計ジャッジ時間 3,994 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 38 ms
65,348 KB
testcase_01 AC 37 ms
65,468 KB
testcase_02 AC 37 ms
65,476 KB
testcase_03 AC 37 ms
65,400 KB
testcase_04 AC 38 ms
65,440 KB
testcase_05 AC 38 ms
65,348 KB
testcase_06 AC 39 ms
65,448 KB
testcase_07 AC 38 ms
65,276 KB
testcase_08 AC 39 ms
65,344 KB
testcase_09 AC 39 ms
65,312 KB
testcase_10 AC 58 ms
65,340 KB
testcase_11 AC 60 ms
65,284 KB
testcase_12 AC 65 ms
65,308 KB
testcase_13 AC 58 ms
65,452 KB
testcase_14 AC 62 ms
65,456 KB
testcase_15 AC 58 ms
65,336 KB
testcase_16 AC 67 ms
65,412 KB
testcase_17 AC 60 ms
65,412 KB
testcase_18 AC 68 ms
65,416 KB
testcase_19 AC 61 ms
65,388 KB
testcase_20 AC 38 ms
65,376 KB
testcase_21 AC 38 ms
65,336 KB
testcase_22 AC 67 ms
65,276 KB
testcase_23 AC 100 ms
65,276 KB
testcase_24 AC 100 ms
65,456 KB
testcase_25 AC 96 ms
65,344 KB
testcase_26 AC 37 ms
65,336 KB
testcase_27 AC 39 ms
65,392 KB
testcase_28 AC 102 ms
65,468 KB
testcase_29 AC 98 ms
65,336 KB
testcase_30 AC 99 ms
65,308 KB
testcase_31 AC 95 ms
65,544 KB
testcase_32 AC 103 ms
65,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;

vector<int> l(8000010, 0), r(8000010, 0);

int main(){
    int n;
    ll d;
    cin >> n >> d;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            l[i*i+j*j]++;
            r[4000000+i*i-j*j]++;
        }
    }
    ll ans = 0;
    for(int i = 0; i < 8000001; i++){
        if(i-d+4000000 > 8000009)  break;
        ans += l[i]*r[i-d+4000000];
    }
    cout << ans << endl;
    return 0;
}
0