結果

問題 No.800 四平方定理
ユーザー noisy_noiminnoisy_noimin
提出日時 2019-03-17 23:57:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,129 bytes
コンパイル時間 724 ms
コンパイル使用メモリ 93,408 KB
実行使用メモリ 128,228 KB
最終ジャッジ日時 2023-09-22 16:03:38
合計ジャッジ時間 4,636 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,404 KB
testcase_01 AC 5 ms
5,452 KB
testcase_02 AC 3 ms
4,572 KB
testcase_03 AC 4 ms
4,984 KB
testcase_04 AC 3 ms
4,620 KB
testcase_05 AC 4 ms
4,904 KB
testcase_06 AC 5 ms
5,892 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 5 ms
5,368 KB
testcase_10 AC 84 ms
65,136 KB
testcase_11 AC 97 ms
72,772 KB
testcase_12 AC 98 ms
71,432 KB
testcase_13 AC 92 ms
67,776 KB
testcase_14 AC 102 ms
72,972 KB
testcase_15 AC 105 ms
72,128 KB
testcase_16 AC 93 ms
73,500 KB
testcase_17 AC 94 ms
73,428 KB
testcase_18 AC 98 ms
73,228 KB
testcase_19 AC 101 ms
73,308 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 WA -
testcase_22 AC 100 ms
73,428 KB
testcase_23 AC 180 ms
128,228 KB
testcase_24 AC 174 ms
128,132 KB
testcase_25 AC 176 ms
127,704 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 RE -
testcase_28 AC 180 ms
127,444 KB
testcase_29 AC 173 ms
127,896 KB
testcase_30 AC 168 ms
127,700 KB
testcase_31 AC 155 ms
118,892 KB
testcase_32 AC 170 ms
128,224 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&&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