結果

問題 No.800 四平方定理
ユーザー izryt(趣味)izryt(趣味)
提出日時 2020-05-24 09:23:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,269 bytes
コンパイル時間 1,223 ms
コンパイル使用メモリ 104,028 KB
実行使用メモリ 128,384 KB
最終ジャッジ日時 2024-04-19 06:20:37
合計ジャッジ時間 24,588 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
10,624 KB
testcase_01 AC 86 ms
6,400 KB
testcase_02 AC 63 ms
5,504 KB
testcase_03 AC 70 ms
5,760 KB
testcase_04 AC 70 ms
5,376 KB
testcase_05 AC 69 ms
5,760 KB
testcase_06 AC 86 ms
6,912 KB
testcase_07 AC 78 ms
6,144 KB
testcase_08 AC 93 ms
6,912 KB
testcase_09 AC 78 ms
6,528 KB
testcase_10 AC 1,425 ms
65,792 KB
testcase_11 AC 1,684 ms
73,344 KB
testcase_12 AC 1,665 ms
71,936 KB
testcase_13 AC 1,587 ms
68,480 KB
testcase_14 AC 1,713 ms
73,216 KB
testcase_15 AC 1,680 ms
73,088 KB
testcase_16 AC 1,759 ms
73,856 KB
testcase_17 AC 1,724 ms
74,112 KB
testcase_18 AC 1,771 ms
73,728 KB
testcase_19 AC 1,826 ms
73,856 KB
testcase_20 AC 16 ms
5,376 KB
testcase_21 AC 22 ms
5,376 KB
testcase_22 AC 1,841 ms
73,856 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

//#define int long long
#define rep(i, n) for (int i=0;i<(int)(n);++i)
#define rep1(i, n) for (int i=1;i<=(int)(n);++i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=r-1;i>=(int)(l);--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;
using ll=long long;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
//int read(){int a;scanf("%lld",&a);return a;}

const int inf = 1e9 + 10;
const int mod = 1e9 + 7;

int N, D;
int xy[8000800];
map<int, int> zw;

signed main()
{
	cin >> N >> D;

	int mx = 0;

	range(x, 1, N + 1) {
		range(y, 1, N + 1) {
			xy[x * x + y * y]++;
		}
	}

	range(z, 1, N + 1) {
		range(w, 1, N + 1) {
			zw[z * z - w * w]++;
		}
	}

	ll ans = 0;

	range(i, 1, 4000040) {
		if (zw.find(D - i) != zw.end())
			ans += xy[i] * zw[D - i];
	}

	printf("%lld\n", ans);
}

0