結果

問題 No.800 四平方定理
ユーザー noisy_noiminnoisy_noimin
提出日時 2019-03-17 23:58:24
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,129 bytes
コンパイル時間 788 ms
コンパイル使用メモリ 94,328 KB
実行使用メモリ 50,376 KB
最終ジャッジ日時 2023-09-22 16:05:59
合計ジャッジ時間 7,796 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
50,184 KB
testcase_01 AC 16 ms
49,892 KB
testcase_02 AC 16 ms
49,916 KB
testcase_03 AC 16 ms
50,156 KB
testcase_04 AC 15 ms
50,000 KB
testcase_05 AC 16 ms
49,868 KB
testcase_06 AC 17 ms
49,932 KB
testcase_07 AC 17 ms
50,016 KB
testcase_08 AC 17 ms
49,952 KB
testcase_09 AC 17 ms
49,944 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 16 ms
49,944 KB
testcase_21 AC 15 ms
49,868 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 15 ms
49,912 KB
testcase_27 AC 16 ms
49,908 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(3000000, 0), cnt2(3000000, 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