結果

問題 No.800 四平方定理
ユーザー face4face4
提出日時 2019-03-17 22:02:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 513 bytes
コンパイル時間 1,027 ms
コンパイル使用メモリ 72,736 KB
実行使用メモリ 65,540 KB
最終ジャッジ日時 2023-09-22 06:19:13
合計ジャッジ時間 4,777 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
65,236 KB
testcase_01 AC 25 ms
65,348 KB
testcase_02 AC 24 ms
65,244 KB
testcase_03 AC 24 ms
65,340 KB
testcase_04 AC 25 ms
65,428 KB
testcase_05 AC 24 ms
65,356 KB
testcase_06 AC 25 ms
65,300 KB
testcase_07 AC 24 ms
65,424 KB
testcase_08 AC 25 ms
65,360 KB
testcase_09 AC 25 ms
65,308 KB
testcase_10 AC 66 ms
65,540 KB
testcase_11 AC 74 ms
65,316 KB
testcase_12 AC 73 ms
65,308 KB
testcase_13 AC 67 ms
65,244 KB
testcase_14 AC 73 ms
65,496 KB
testcase_15 AC 73 ms
65,236 KB
testcase_16 AC 73 ms
65,356 KB
testcase_17 AC 72 ms
65,304 KB
testcase_18 AC 75 ms
65,308 KB
testcase_19 AC 76 ms
65,428 KB
testcase_20 AC 23 ms
65,384 KB
testcase_21 AC 24 ms
65,496 KB
testcase_22 AC 73 ms
65,236 KB
testcase_23 AC 125 ms
65,368 KB
testcase_24 AC 124 ms
65,352 KB
testcase_25 AC 125 ms
65,304 KB
testcase_26 AC 23 ms
65,324 KB
testcase_27 AC 26 ms
65,344 KB
testcase_28 AC 121 ms
65,236 KB
testcase_29 AC 122 ms
65,500 KB
testcase_30 AC 120 ms
65,432 KB
testcase_31 AC 112 ms
65,300 KB
testcase_32 AC 121 ms
65,484 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