結果

問題 No.800 四平方定理
ユーザー ohreitetsuohreitetsu
提出日時 2019-04-25 22:13:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 780 bytes
コンパイル時間 574 ms
コンパイル使用メモリ 77,416 KB
実行使用メモリ 64,768 KB
最終ジャッジ日時 2024-05-01 10:50:35
合計ジャッジ時間 4,972 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
13,756 KB
testcase_01 AC 26 ms
5,760 KB
testcase_02 AC 18 ms
5,376 KB
testcase_03 AC 19 ms
5,376 KB
testcase_04 AC 19 ms
5,376 KB
testcase_05 AC 20 ms
5,376 KB
testcase_06 AC 29 ms
6,144 KB
testcase_07 AC 33 ms
6,400 KB
testcase_08 AC 42 ms
7,168 KB
testcase_09 AC 28 ms
5,632 KB
testcase_10 AC 1,873 ms
62,336 KB
testcase_11 AC 1,925 ms
64,768 KB
testcase_12 TLE -
testcase_13 AC 1,610 ms
56,448 KB
testcase_14 AC 1,703 ms
60,032 KB
testcase_15 TLE -
testcase_16 AC 1,746 ms
60,672 KB
testcase_17 AC 1,716 ms
60,544 KB
testcase_18 TLE -
testcase_19 TLE -
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 2 ms
6,940 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