結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2019-03-21 17:00:11 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 99 ms / 2,000 ms |
| コード長 | 1,058 bytes |
| コンパイル時間 | 716 ms |
| コンパイル使用メモリ | 83,540 KB |
| 実行使用メモリ | 53,760 KB |
| 最終ジャッジ日時 | 2024-09-19 01:46:46 |
| 合計ジャッジ時間 | 2,940 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
コンパイルメッセージ
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);
| ~~~~~^~~~~~~~~~~~~~~~
ソースコード
/* -*- 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;
}
tnakao0123