結果

問題 No.800 四平方定理
ユーザー noisy_noiminnoisy_noimin
提出日時 2019-03-17 23:58:51
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,129 bytes
コンパイル時間 720 ms
コンパイル使用メモリ 93,852 KB
実行使用メモリ 81,400 KB
最終ジャッジ日時 2023-09-22 16:08:36
合計ジャッジ時間 7,025 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
81,216 KB
testcase_01 AC 25 ms
81,048 KB
testcase_02 AC 24 ms
81,188 KB
testcase_03 AC 23 ms
81,044 KB
testcase_04 AC 24 ms
81,052 KB
testcase_05 AC 24 ms
81,112 KB
testcase_06 AC 23 ms
81,164 KB
testcase_07 AC 24 ms
81,176 KB
testcase_08 AC 24 ms
81,152 KB
testcase_09 AC 24 ms
81,116 KB
testcase_10 AC 78 ms
81,048 KB
testcase_11 AC 83 ms
81,060 KB
testcase_12 AC 85 ms
81,092 KB
testcase_13 AC 79 ms
81,048 KB
testcase_14 AC 85 ms
81,112 KB
testcase_15 AC 84 ms
81,132 KB
testcase_16 AC 84 ms
81,128 KB
testcase_17 AC 83 ms
81,128 KB
testcase_18 AC 90 ms
81,124 KB
testcase_19 AC 88 ms
81,312 KB
testcase_20 AC 22 ms
81,112 KB
testcase_21 AC 22 ms
81,124 KB
testcase_22 AC 90 ms
81,224 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 23 ms
81,108 KB
testcase_27 AC 23 ms
81,328 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
権限があれば一括ダウンロードができます

ソースコード

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(5000000, 0), cnt2(5000000, 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&&d-i+n*n>=0;++i) {
        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