結果

問題 No.800 四平方定理
ユーザー noisy_noiminnoisy_noimin
提出日時 2019-03-18 00:01:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,126 bytes
コンパイル時間 831 ms
コンパイル使用メモリ 99,232 KB
実行使用メモリ 13,392 KB
最終ジャッジ日時 2023-09-22 16:10:13
合計ジャッジ時間 4,854 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
13,392 KB
testcase_01 AC 40 ms
8,760 KB
testcase_02 AC 28 ms
7,080 KB
testcase_03 AC 31 ms
7,872 KB
testcase_04 AC 26 ms
7,036 KB
testcase_05 AC 31 ms
7,508 KB
testcase_06 AC 50 ms
9,892 KB
testcase_07 AC 37 ms
8,324 KB
testcase_08 AC 51 ms
10,216 KB
testcase_09 AC 43 ms
8,952 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

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;
    
    map<ll, ll> cnt1, cnt2;

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

    ll ans = 0LL;
    for(auto itr=cnt1.begin();itr!=cnt1.end();++itr) {
        ans += ((itr->second) * cnt2[d-(itr->first)]) % MOD;
        ans %= MOD;
        // cerr << i << ": " << cnt1[i] << " " << d-i << ": " << cnt2[d-i+n*n] << endl;
    }

    cout << ans << endl;

}
0