結果

問題 No.800 四平方定理
ユーザー ats5515
提出日時 2019-03-17 23:13:20
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 640 bytes
コンパイル時間 525 ms
コンパイル使用メモリ 86,424 KB
実行使用メモリ 22,592 KB
最終ジャッジ日時 2024-07-08 02:08:34
合計ジャッジ時間 3,733 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 RE * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
int MOD = 1000000007;
int mp[5001000];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, D;
	cin >> N >> D;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			int t = i * i - j * j + D;
			if (t < 0)break;
			mp[t]++;
		}
	}
	long long res = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			res += (long long)mp[i * i + j * j];
		}
	}

	cout << res << endl;
}
0