結果

問題 No.800 四平方定理
ユーザー karinohitokarinohito
提出日時 2021-08-19 23:23:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 746 bytes
コンパイル時間 1,813 ms
コンパイル使用メモリ 170,536 KB
実行使用メモリ 109,312 KB
最終ジャッジ日時 2024-04-21 02:53:51
合計ジャッジ時間 6,514 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
13,756 KB
testcase_01 AC 27 ms
7,424 KB
testcase_02 AC 17 ms
6,016 KB
testcase_03 AC 21 ms
6,528 KB
testcase_04 AC 23 ms
6,400 KB
testcase_05 AC 23 ms
6,784 KB
testcase_06 AC 30 ms
7,680 KB
testcase_07 AC 42 ms
9,472 KB
testcase_08 AC 62 ms
11,648 KB
testcase_09 AC 27 ms
7,040 KB
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 AC 1,598 ms
85,760 KB
testcase_14 AC 1,761 ms
98,176 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

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;
    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;
    for(auto p:ZW){
        an+=ZW[p.first]*XY[p.first];
    }
    cout<<an<<endl;

}
0