結果

問題 No.800 四平方定理
ユーザー olpheolphe
提出日時 2019-03-17 21:25:22
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 901 bytes
コンパイル時間 800 ms
使用メモリ 81,412 KB
最終ジャッジ日時 2023-02-11 03:42:07
合計ジャッジ時間 3,579 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 21 ms
80,984 KB
testcase_01 AC 20 ms
81,080 KB
testcase_02 AC 21 ms
81,100 KB
testcase_03 AC 20 ms
80,988 KB
testcase_04 AC 21 ms
80,984 KB
testcase_05 AC 20 ms
81,092 KB
testcase_06 AC 21 ms
81,412 KB
testcase_07 AC 20 ms
81,052 KB
testcase_08 AC 21 ms
80,984 KB
testcase_09 AC 21 ms
81,088 KB
testcase_10 AC 34 ms
80,988 KB
testcase_11 AC 37 ms
80,984 KB
testcase_12 AC 37 ms
80,988 KB
testcase_13 AC 36 ms
80,992 KB
testcase_14 AC 37 ms
80,992 KB
testcase_15 AC 36 ms
81,140 KB
testcase_16 AC 37 ms
80,988 KB
testcase_17 AC 37 ms
81,056 KB
testcase_18 AC 37 ms
81,088 KB
testcase_19 AC 36 ms
80,984 KB
testcase_20 AC 20 ms
80,988 KB
testcase_21 AC 21 ms
81,088 KB
testcase_22 AC 36 ms
80,992 KB
testcase_23 AC 53 ms
81,084 KB
testcase_24 AC 55 ms
81,056 KB
testcase_25 AC 53 ms
80,988 KB
testcase_26 AC 20 ms
80,988 KB
testcase_27 AC 19 ms
81,088 KB
testcase_28 AC 57 ms
81,100 KB
testcase_29 AC 53 ms
81,088 KB
testcase_30 AC 57 ms
80,996 KB
testcase_31 AC 51 ms
80,984 KB
testcase_32 AC 56 ms
81,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> N >> K;
	vector<int>m(20000000);
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			m[i*i - j * j+10000000]++;
		}
	}
	long long int ans = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			int box = i * i + j * j - K;
			ans += m[box+10000000];
		}
	}
	cout << ans << endl;
	return 0;
}
0