結果

問題 No.800 四平方定理
ユーザー yomayoma
提出日時 2019-10-15 15:54:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 919 bytes
コンパイル時間 1,475 ms
コンパイル使用メモリ 165,372 KB
実行使用メモリ 81,288 KB
最終ジャッジ日時 2023-08-28 14:30:06
合計ジャッジ時間 5,277 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
81,056 KB
testcase_01 AC 32 ms
81,116 KB
testcase_02 AC 32 ms
81,104 KB
testcase_03 AC 32 ms
81,124 KB
testcase_04 AC 32 ms
81,028 KB
testcase_05 AC 32 ms
81,124 KB
testcase_06 AC 33 ms
81,108 KB
testcase_07 AC 33 ms
81,156 KB
testcase_08 AC 32 ms
81,076 KB
testcase_09 AC 31 ms
81,180 KB
testcase_10 AC 49 ms
81,156 KB
testcase_11 AC 52 ms
81,096 KB
testcase_12 AC 53 ms
81,012 KB
testcase_13 AC 49 ms
81,120 KB
testcase_14 AC 50 ms
81,096 KB
testcase_15 AC 53 ms
81,124 KB
testcase_16 AC 51 ms
81,060 KB
testcase_17 AC 50 ms
81,156 KB
testcase_18 AC 55 ms
81,092 KB
testcase_19 AC 54 ms
81,064 KB
testcase_20 AC 32 ms
81,160 KB
testcase_21 AC 31 ms
81,100 KB
testcase_22 AC 54 ms
81,116 KB
testcase_23 AC 90 ms
81,100 KB
testcase_24 AC 84 ms
81,120 KB
testcase_25 AC 88 ms
81,072 KB
testcase_26 AC 31 ms
81,008 KB
testcase_27 AC 32 ms
81,056 KB
testcase_28 AC 81 ms
81,160 KB
testcase_29 AC 86 ms
81,120 KB
testcase_30 AC 83 ms
81,072 KB
testcase_31 AC 78 ms
81,056 KB
testcase_32 AC 83 ms
81,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define EM 1000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
LL mod = 1e9+7;
using vint = vector<int>;
using vLL = vector<LL>;
using vvint = vector<vector<int>>;
using vvLL = vector<vector<LL>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int N, D;
    cin >> N >> D;
    vector<int> le(1e7, 0), ri(1e7, 0);
    for(int x = 1;x <= N;x++){
        for(int y = 1;y <= N;y++){
            le[x*x + y*y]++;
        }
    }
    for(int z = 1;z <= N;z++){
        for(int w = 1;w <= N;w++){
            int id = w*w - z*z + D;
            if(id > 0)  ri[id]++;
        }
    }
    LL ans = 0;
    for(int i = 2;i <= 1e7;i++){
        ans += le[i]*ri[i];
    }
    cout << ans << endl;
}
0