結果

問題 No.800 四平方定理
ユーザー karinohitokarinohito
提出日時 2021-08-19 23:25:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 794 bytes
コンパイル時間 1,733 ms
コンパイル使用メモリ 164,492 KB
実行使用メモリ 65,936 KB
最終ジャッジ日時 2024-04-21 02:55:07
合計ジャッジ時間 5,406 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
65,688 KB
testcase_01 AC 28 ms
65,724 KB
testcase_02 AC 27 ms
65,756 KB
testcase_03 AC 26 ms
65,632 KB
testcase_04 AC 27 ms
65,856 KB
testcase_05 AC 26 ms
65,764 KB
testcase_06 AC 28 ms
65,724 KB
testcase_07 AC 30 ms
65,792 KB
testcase_08 AC 28 ms
65,708 KB
testcase_09 AC 27 ms
65,880 KB
testcase_10 AC 64 ms
65,712 KB
testcase_11 AC 60 ms
65,776 KB
testcase_12 AC 71 ms
65,660 KB
testcase_13 AC 49 ms
65,780 KB
testcase_14 AC 60 ms
65,764 KB
testcase_15 AC 66 ms
65,700 KB
testcase_16 AC 58 ms
65,724 KB
testcase_17 AC 55 ms
65,572 KB
testcase_18 AC 77 ms
65,872 KB
testcase_19 AC 73 ms
65,636 KB
testcase_20 AC 25 ms
65,704 KB
testcase_21 AC 26 ms
65,660 KB
testcase_22 AC 75 ms
65,804 KB
testcase_23 RE -
testcase_24 AC 91 ms
65,864 KB
testcase_25 RE -
testcase_26 AC 29 ms
65,724 KB
testcase_27 AC 25 ms
65,800 KB
testcase_28 AC 88 ms
65,572 KB
testcase_29 RE -
testcase_30 AC 89 ms
65,780 KB
testcase_31 AC 84 ms
65,572 KB
testcase_32 RE -
権限があれば一括ダウンロードができます

ソースコード

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+5,0);
    vll ZW(2000*2000+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+2){
        an+=XY[i]*ZW[i];
    }
    cout<<an<<endl;

}
0