結果

問題 No.800 四平方定理
ユーザー karinohitokarinohito
提出日時 2021-08-19 23:25:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 800 bytes
コンパイル時間 1,782 ms
コンパイル使用メモリ 164,232 KB
実行使用メモリ 81,408 KB
最終ジャッジ日時 2024-04-21 02:55:57
合計ジャッジ時間 4,662 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
65,792 KB
testcase_01 AC 29 ms
65,664 KB
testcase_02 AC 30 ms
65,848 KB
testcase_03 AC 29 ms
65,792 KB
testcase_04 AC 28 ms
65,832 KB
testcase_05 AC 29 ms
65,792 KB
testcase_06 AC 28 ms
65,536 KB
testcase_07 AC 29 ms
67,288 KB
testcase_08 AC 30 ms
70,016 KB
testcase_09 AC 27 ms
65,664 KB
testcase_10 AC 72 ms
73,088 KB
testcase_11 AC 67 ms
69,564 KB
testcase_12 AC 78 ms
74,432 KB
testcase_13 AC 57 ms
65,768 KB
testcase_14 AC 63 ms
65,664 KB
testcase_15 AC 73 ms
73,728 KB
testcase_16 AC 63 ms
65,664 KB
testcase_17 AC 63 ms
65,792 KB
testcase_18 AC 88 ms
81,280 KB
testcase_19 AC 83 ms
81,284 KB
testcase_20 AC 29 ms
65,664 KB
testcase_21 AC 28 ms
65,536 KB
testcase_22 AC 88 ms
81,280 KB
testcase_23 AC 129 ms
81,408 KB
testcase_24 AC 101 ms
65,792 KB
testcase_25 AC 129 ms
81,408 KB
testcase_26 AC 27 ms
65,664 KB
testcase_27 AC 34 ms
81,280 KB
testcase_28 AC 109 ms
65,768 KB
testcase_29 AC 122 ms
73,584 KB
testcase_30 AC 104 ms
65,664 KB
testcase_31 AC 96 ms
65,664 KB
testcase_32 AC 108 ms
67,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(A) A.begin(),A.end()
using vll = vector<ll>;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using Graph = vector<vector<ll>>;

ll gcd(ll(a), ll(b)) {
    ll c = a;
    while (a % b != 0) {
        c = a % b;
        a = b;
        b = c;
    }
    return b;
}

int main() {
    ll N,D;
    cin>>N>>D;
    //map<ll,ll> XY,ZW;
    vll XY(2000*2000+D+5,0);
    vll ZW(2000*2000+D+5,0);
    for(ll X=1;X<=N;X++){
        for(ll Y=1;Y<=N;Y++){
            if(X*X+Y*Y<=N*N+D){
                XY[X*X+Y*Y]++;
            }
            if(X*X+D-Y*Y>=2){
                ZW[X*X+D-Y*Y]++;
            }
        }
    }
    ll an=0;
    rep(i,2000*2000+D+2){
        an+=XY[i]*ZW[i];
    }
    cout<<an<<endl;

}
0