結果

問題 No.800 四平方定理
ユーザー noisy_noiminnoisy_noimin
提出日時 2019-03-18 00:04:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 176 ms / 2,000 ms
コード長 1,172 bytes
コンパイル時間 865 ms
コンパイル使用メモリ 93,968 KB
実行使用メモリ 128,092 KB
最終ジャッジ日時 2023-09-22 16:10:31
合計ジャッジ時間 4,370 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,396 KB
testcase_01 AC 3 ms
5,432 KB
testcase_02 AC 3 ms
4,888 KB
testcase_03 AC 3 ms
4,840 KB
testcase_04 AC 3 ms
4,640 KB
testcase_05 AC 3 ms
4,892 KB
testcase_06 AC 4 ms
6,036 KB
testcase_07 AC 4 ms
5,152 KB
testcase_08 AC 4 ms
6,016 KB
testcase_09 AC 4 ms
5,452 KB
testcase_10 AC 78 ms
65,028 KB
testcase_11 AC 88 ms
72,688 KB
testcase_12 AC 87 ms
71,376 KB
testcase_13 AC 81 ms
67,860 KB
testcase_14 AC 87 ms
72,688 KB
testcase_15 AC 88 ms
72,144 KB
testcase_16 AC 88 ms
73,424 KB
testcase_17 AC 92 ms
73,420 KB
testcase_18 AC 92 ms
72,904 KB
testcase_19 AC 91 ms
73,236 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 90 ms
73,432 KB
testcase_23 AC 168 ms
128,060 KB
testcase_24 AC 163 ms
128,092 KB
testcase_25 AC 176 ms
127,748 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 161 ms
127,560 KB
testcase_29 AC 161 ms
127,800 KB
testcase_30 AC 160 ms
127,556 KB
testcase_31 AC 148 ms
118,928 KB
testcase_32 AC 164 ms
128,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};



int main() {
    ll n, d;
    cin >> n >> d;
    
    vector<ll> cnt1(2*n*n+1, 0), cnt2(2*n*n+1, 0);

    for(int i=1;i<=n;++i) {
        for(int j=1;j<=n;++j) {
            ++cnt1[i*i+j*j];
            ++cnt2[i*i-j*j + n*n];
        }
    }

    ll ans = 0LL;
    for(int i=1;i<=2*n*n;++i) {
        if(d-i+n*n < 0 || 2*n*n < d-i+n*n) continue;
        ans += (cnt1[i] * cnt2[d-i+n*n]) % MOD;
        ans %= MOD;
        // cerr << i << ": " << cnt1[i] << " " << d-i << ": " << cnt2[d-i+n*n] << endl;
    }

    cout << ans << endl;

}
0