結果

問題 No.800 四平方定理
ユーザー pekempeypekempey
提出日時 2019-03-17 21:24:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 972 bytes
コンパイル時間 744 ms
コンパイル使用メモリ 83,116 KB
実行使用メモリ 108,308 KB
最終ジャッジ日時 2023-09-22 03:26:00
合計ジャッジ時間 4,894 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
10,252 KB
testcase_01 AC 36 ms
7,424 KB
testcase_02 AC 24 ms
6,196 KB
testcase_03 AC 29 ms
6,668 KB
testcase_04 AC 24 ms
6,064 KB
testcase_05 AC 28 ms
6,620 KB
testcase_06 AC 46 ms
8,264 KB
testcase_07 AC 34 ms
7,096 KB
testcase_08 AC 46 ms
8,528 KB
testcase_09 AC 39 ms
7,504 KB
testcase_10 TLE -
testcase_11 TLE -
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 <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

int main() {
  int N, D;
  cin >> N >> D;
  map<int, int> mp1;
  map<int, int> mp2;
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      mp1[i*i + j*j]++;
      mp2[i*i - j*j + D]++;
    }
  }
  long long ans = 0;
  for (auto e : mp1) {
    ans += (long long)e.second * mp2[e.first];
  }
  cout << ans << endl;
}
0