結果

問題 No.800 四平方定理
ユーザー pekempeypekempey
提出日時 2019-03-17 21:27:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 1,085 bytes
コンパイル時間 609 ms
コンパイル使用メモリ 74,844 KB
実行使用メモリ 55,176 KB
最終ジャッジ日時 2023-09-22 03:39:35
合計ジャッジ時間 3,469 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
5,804 KB
testcase_01 AC 10 ms
5,732 KB
testcase_02 AC 9 ms
5,592 KB
testcase_03 AC 10 ms
5,712 KB
testcase_04 AC 10 ms
5,672 KB
testcase_05 AC 10 ms
5,696 KB
testcase_06 AC 10 ms
5,824 KB
testcase_07 AC 10 ms
5,916 KB
testcase_08 AC 11 ms
6,144 KB
testcase_09 AC 10 ms
5,904 KB
testcase_10 AC 48 ms
29,944 KB
testcase_11 AC 50 ms
32,016 KB
testcase_12 AC 55 ms
34,068 KB
testcase_13 AC 44 ms
29,944 KB
testcase_14 AC 48 ms
32,044 KB
testcase_15 AC 53 ms
34,196 KB
testcase_16 AC 49 ms
32,164 KB
testcase_17 AC 47 ms
32,048 KB
testcase_18 AC 59 ms
36,092 KB
testcase_19 AC 60 ms
36,140 KB
testcase_20 AC 9 ms
5,564 KB
testcase_21 AC 10 ms
5,448 KB
testcase_22 AC 61 ms
36,140 KB
testcase_23 AC 106 ms
55,176 KB
testcase_24 AC 92 ms
51,016 KB
testcase_25 AC 109 ms
55,092 KB
testcase_26 AC 9 ms
5,376 KB
testcase_27 AC 11 ms
7,476 KB
testcase_28 AC 91 ms
50,812 KB
testcase_29 AC 98 ms
53,232 KB
testcase_30 AC 92 ms
50,996 KB
testcase_31 AC 88 ms
50,532 KB
testcase_32 AC 95 ms
50,964 KB
権限があれば一括ダウンロードができます

ソースコード

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 C1[2000*2000 + 2000*2000 + 1];
int C2[2000*2000 + 2000*2000 + 1];

int main() {
  int N, D;
  cin >> N >> D;
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      C1[i*i + j*j]++;
      int k = i*i - j*j + D;
      if (0 <= k && k <= 2000*2000 + 2000*2000) {
        C2[k]++;
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i <= 2000*2000 + 2000*2000; i++) {
    ans += C1[i] * C2[i];
  }
  cout << ans << endl;
}
0