結果

問題 No.800 四平方定理
ユーザー izryt(趣味)izryt(趣味)
提出日時 2020-05-24 09:29:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,245 bytes
コンパイル時間 1,180 ms
コンパイル使用メモリ 102,816 KB
実行使用メモリ 88,488 KB
最終ジャッジ日時 2024-04-19 06:40:48
合計ジャッジ時間 29,990 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
6,812 KB
testcase_01 AC 13 ms
6,944 KB
testcase_02 AC 9 ms
6,940 KB
testcase_03 AC 10 ms
6,940 KB
testcase_04 AC 9 ms
6,940 KB
testcase_05 AC 10 ms
6,944 KB
testcase_06 AC 15 ms
6,940 KB
testcase_07 AC 12 ms
6,940 KB
testcase_08 AC 15 ms
6,944 KB
testcase_09 AC 13 ms
6,944 KB
testcase_10 AC 870 ms
45,816 KB
testcase_11 AC 1,006 ms
49,652 KB
testcase_12 AC 992 ms
49,016 KB
testcase_13 AC 993 ms
47,228 KB
testcase_14 AC 1,068 ms
49,660 KB
testcase_15 AC 1,056 ms
49,524 KB
testcase_16 AC 1,081 ms
49,912 KB
testcase_17 AC 1,072 ms
49,912 KB
testcase_18 AC 989 ms
49,784 KB
testcase_19 AC 974 ms
49,912 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 1,066 ms
50,044 KB
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 1 ms
6,940 KB
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 AC 1,824 ms
83,880 KB
testcase_32 TLE -
権限があれば一括ダウンロードができます

ソースコード

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>
#include <unordered_map>

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];
unordered_map<int, int> zw;

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

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

	ll ans = 0;

	range(x, 1, N + 1) {
		range(y, 1, N + 1) {
			if (zw.count(D - (x * x + y * y))) ans += zw[D - (x * x + y * y)];
		}
	}

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

0