結果

問題 No.800 四平方定理
ユーザー uchiiiiuchiiii
提出日時 2020-08-11 03:29:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 1,368 bytes
コンパイル時間 3,559 ms
コンパイル使用メモリ 213,888 KB
実行使用メモリ 55,248 KB
最終ジャッジ日時 2024-04-17 16:37:17
合計ジャッジ時間 3,968 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
6,812 KB
testcase_01 AC 4 ms
8,028 KB
testcase_02 AC 5 ms
6,944 KB
testcase_03 AC 5 ms
6,944 KB
testcase_04 AC 4 ms
6,940 KB
testcase_05 AC 4 ms
6,940 KB
testcase_06 AC 5 ms
6,940 KB
testcase_07 AC 4 ms
6,940 KB
testcase_08 AC 6 ms
10,124 KB
testcase_09 AC 4 ms
6,940 KB
testcase_10 AC 19 ms
31,708 KB
testcase_11 AC 20 ms
35,344 KB
testcase_12 AC 18 ms
34,908 KB
testcase_13 AC 16 ms
30,740 KB
testcase_14 AC 21 ms
31,796 KB
testcase_15 AC 21 ms
35,420 KB
testcase_16 AC 20 ms
33,132 KB
testcase_17 AC 18 ms
33,232 KB
testcase_18 AC 20 ms
36,060 KB
testcase_19 AC 20 ms
36,060 KB
testcase_20 AC 5 ms
6,940 KB
testcase_21 AC 4 ms
6,940 KB
testcase_22 AC 22 ms
36,576 KB
testcase_23 AC 37 ms
55,248 KB
testcase_24 AC 35 ms
49,792 KB
testcase_25 AC 38 ms
55,116 KB
testcase_26 AC 4 ms
6,940 KB
testcase_27 AC 4 ms
7,648 KB
testcase_28 AC 36 ms
51,036 KB
testcase_29 AC 37 ms
53,232 KB
testcase_30 AC 34 ms
51,092 KB
testcase_31 AC 33 ms
49,008 KB
testcase_32 AC 35 ms
51,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>inline int popcount(T a) {return __builtin_popcount(a);}
//-------------------
constexpr int MX = 2e3 * 2e3 * 2 + 3;
int mp1[MX];
int mp2[MX];
int main() {
    cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15);
    int n,d; cin >> n >> d;
    // unordered_map<int, int> mp1;
    FOR(x,1,n) {
        FOR(y,1,n) {
            mp1[x*x+y*y]++;
        }
    }

    // unordered_map<int, int> mp2;
    FOR(z,1,n) {
        FOR(w,1,n) {
            if(w*w+d-z*z > 1)
            mp2[w*w+d-z*z]++;
        }
    }

    ll ans = 0;
    rep(i, MX-1) {
        ans += mp1[i] * mp2[i];
    }

    cout << ans << endl;
    return 0;
}
0