結果

問題 No.800 四平方定理
ユーザー tnakao0123tnakao0123
提出日時 2019-03-21 17:00:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 1,058 bytes
コンパイル時間 651 ms
コンパイル使用メモリ 84,852 KB
実行使用メモリ 57,840 KB
最終ジャッジ日時 2023-10-19 05:27:46
合計ジャッジ時間 3,037 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
8,068 KB
testcase_01 AC 3 ms
8,216 KB
testcase_02 AC 3 ms
8,120 KB
testcase_03 AC 3 ms
8,148 KB
testcase_04 AC 3 ms
8,136 KB
testcase_05 AC 3 ms
8,168 KB
testcase_06 AC 3 ms
8,260 KB
testcase_07 AC 3 ms
8,320 KB
testcase_08 AC 4 ms
9,960 KB
testcase_09 AC 3 ms
8,216 KB
testcase_10 AC 33 ms
33,156 KB
testcase_11 AC 34 ms
35,204 KB
testcase_12 AC 37 ms
35,204 KB
testcase_13 AC 29 ms
31,108 KB
testcase_14 AC 35 ms
33,156 KB
testcase_15 AC 36 ms
35,204 KB
testcase_16 AC 34 ms
33,156 KB
testcase_17 AC 34 ms
33,156 KB
testcase_18 AC 42 ms
37,252 KB
testcase_19 AC 40 ms
37,252 KB
testcase_20 AC 2 ms
5,864 KB
testcase_21 AC 3 ms
5,864 KB
testcase_22 AC 37 ms
37,252 KB
testcase_23 AC 92 ms
57,840 KB
testcase_24 AC 80 ms
50,124 KB
testcase_25 AC 89 ms
56,160 KB
testcase_26 AC 2 ms
4,972 KB
testcase_27 AC 1 ms
5,028 KB
testcase_28 AC 81 ms
49,912 KB
testcase_29 AC 88 ms
55,772 KB
testcase_30 AC 80 ms
53,708 KB
testcase_31 AC 72 ms
51,588 KB
testcase_32 AC 82 ms
53,744 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:46:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   46 |   scanf("%d%d", &n, &d);
      |   ~~~~~^~~~~~~~~~~~~~~~

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 800.cc:  No.800 四平方定理 - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 2000;
const int MAX_NN2 = MAX_N * MAX_N * 2;

/* typedef */

typedef long long ll;

/* global variables */

int cxy[MAX_NN2 + 1], czw[MAX_NN2 + 1];

/* subroutines */

/* main */

int main() {
  int n, d;
  scanf("%d%d", &n, &d);
  int nn2 = n * n * 2;

  for (int x = 1; x <= n; x++)
    for (int y = 1; y <= n; y++)
      cxy[x * x + y * y]++;

  for (int z = 1; z <= n; z++)
    for (int w = 1; w <= n; w++) {
      int k = w * w - z * z + d;
      if (k >= 2 && k <= nn2) czw[k]++;
    }

  ll sum = 0;
  for (int k = 2; k <= nn2; k++)
    sum += (ll)cxy[k] * czw[k];

  printf("%lld\n", sum);
  return 0;
}
0