結果

問題 No.800 四平方定理
ユーザー ohreitetsuohreitetsu
提出日時 2019-04-25 22:13:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 780 bytes
コンパイル時間 720 ms
コンパイル使用メモリ 76,112 KB
実行使用メモリ 76,140 KB
最終ジャッジ日時 2023-08-13 18:11:55
合計ジャッジ時間 25,594 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
4,848 KB
testcase_01 AC 29 ms
5,576 KB
testcase_02 AC 19 ms
4,888 KB
testcase_03 AC 21 ms
5,080 KB
testcase_04 AC 20 ms
4,952 KB
testcase_05 AC 23 ms
5,184 KB
testcase_06 AC 33 ms
5,964 KB
testcase_07 AC 36 ms
6,148 KB
testcase_08 AC 48 ms
7,148 KB
testcase_09 AC 28 ms
5,660 KB
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 AC 1,811 ms
56,164 KB
testcase_14 AC 1,982 ms
59,992 KB
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 AC 1 ms
4,384 KB
testcase_21 AC 2 ms
4,388 KB
testcase_22 TLE -
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 <map>
using namespace std;
int main(int argc, char* argv[])
{
	int N,D;
	cin>>N>>D;
	map<int,int> xyMap;
	map<int,int> wzMap;
	map<int,int>::iterator mit;
	for (int x=1;x<=N;x++){
		for (int y=1;y<=N;y++){
			int xy=x*x+y*y;
			mit=xyMap.find(xy);
			if (mit==xyMap.end()){
				xyMap[xy]=1;
			}else{
				(*mit).second++;
			}
			int wz=x*x-y*y+D;
			if (wz<2){
				continue;
			}
			mit=wzMap.find(wz);
			if (mit==wzMap.end()){
				wzMap[wz]=1;
			}else{
				(*mit).second++;
			}
		}
	}
	int ans=0;
	map<int,int>::iterator mit1;
	for (mit=xyMap.begin();mit!=xyMap.end();mit++){
		mit1=wzMap.find((*mit).first);
		if (mit1!=wzMap.end()){
			ans+=(*mit).second * (*mit1).second;
		}
	}
	xyMap.clear();
	wzMap.clear();
	cout<<ans<<endl;		
	return 0;
}
0