結果

問題 No.800 四平方定理
ユーザー karinohitokarinohito
提出日時 2021-08-19 23:25:49
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 800 bytes
コンパイル時間 1,688 ms
コンパイル使用メモリ 167,276 KB
実行使用メモリ 81,244 KB
最終ジャッジ日時 2023-08-03 03:24:07
合計ジャッジ時間 4,947 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
65,516 KB
testcase_01 AC 27 ms
65,540 KB
testcase_02 AC 26 ms
65,404 KB
testcase_03 AC 27 ms
65,448 KB
testcase_04 AC 26 ms
65,596 KB
testcase_05 AC 27 ms
65,624 KB
testcase_06 AC 28 ms
65,472 KB
testcase_07 AC 28 ms
67,060 KB
testcase_08 AC 28 ms
69,836 KB
testcase_09 AC 26 ms
65,556 KB
testcase_10 AC 61 ms
72,968 KB
testcase_11 AC 58 ms
69,380 KB
testcase_12 AC 63 ms
74,296 KB
testcase_13 AC 51 ms
65,580 KB
testcase_14 AC 55 ms
65,476 KB
testcase_15 AC 65 ms
73,768 KB
testcase_16 AC 57 ms
65,440 KB
testcase_17 AC 54 ms
65,572 KB
testcase_18 AC 70 ms
81,236 KB
testcase_19 AC 73 ms
81,156 KB
testcase_20 AC 25 ms
65,492 KB
testcase_21 AC 26 ms
65,444 KB
testcase_22 AC 70 ms
81,184 KB
testcase_23 AC 105 ms
81,136 KB
testcase_24 AC 84 ms
65,576 KB
testcase_25 AC 102 ms
81,108 KB
testcase_26 AC 26 ms
65,512 KB
testcase_27 AC 30 ms
81,244 KB
testcase_28 AC 88 ms
65,424 KB
testcase_29 AC 97 ms
73,580 KB
testcase_30 AC 88 ms
65,432 KB
testcase_31 AC 83 ms
65,432 KB
testcase_32 AC 94 ms
67,212 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