結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
4,740 KB
testcase_01 AC 27 ms
5,572 KB
testcase_02 AC 19 ms
4,912 KB
testcase_03 AC 20 ms
5,104 KB
testcase_04 AC 19 ms
4,980 KB
testcase_05 AC 22 ms
5,188 KB
testcase_06 AC 31 ms
6,148 KB
testcase_07 AC 32 ms
6,148 KB
testcase_08 AC 42 ms
7,116 KB
testcase_09 AC 27 ms
5,868 KB
testcase_10 AC 1,748 ms
62,424 KB
testcase_11 AC 1,838 ms
65,112 KB
testcase_12 AC 1,943 ms
68,796 KB
testcase_13 AC 1,535 ms
56,208 KB
testcase_14 AC 1,569 ms
59,940 KB
testcase_15 AC 1,927 ms
69,104 KB
testcase_16 AC 1,619 ms
60,556 KB
testcase_17 AC 1,605 ms
60,608 KB
testcase_18 TLE -
testcase_19 TLE -
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 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++;
			}
		}
	}
	mit=xyMap.begin();
	int MinV=(*mit).first;
	for (int w=1;w<=N;w++){
		for (int z=1;z<=N;z++){
			int wz=w*w-z*z+D;
			if (wz<MinV){
				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