結果

問題 No.800 四平方定理
ユーザー kaagekaage
提出日時 2019-03-17 22:16:33
言語 C++11
(gcc 8.5.0)
結果
AC  
実行時間 1,346 ms / 2,000 ms
コード長 679 bytes
コンパイル時間 1,095 ms
使用メモリ 36,056 KB
最終ジャッジ日時 2023-02-11 08:13:06
合計ジャッジ時間 19,034 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 8 ms
3,816 KB
testcase_01 AC 16 ms
4,200 KB
testcase_02 AC 11 ms
3,688 KB
testcase_03 AC 12 ms
3,760 KB
testcase_04 AC 12 ms
3,688 KB
testcase_05 AC 14 ms
3,668 KB
testcase_06 AC 18 ms
4,080 KB
testcase_07 AC 17 ms
4,132 KB
testcase_08 AC 11 ms
4,132 KB
testcase_09 AC 15 ms
4,024 KB
testcase_10 AC 601 ms
19,548 KB
testcase_11 AC 629 ms
36,056 KB
testcase_12 AC 691 ms
36,036 KB
testcase_13 AC 493 ms
19,516 KB
testcase_14 AC 547 ms
36,040 KB
testcase_15 AC 691 ms
36,040 KB
testcase_16 AC 551 ms
35,968 KB
testcase_17 AC 553 ms
35,924 KB
testcase_18 AC 802 ms
35,808 KB
testcase_19 AC 805 ms
35,832 KB
testcase_20 AC 1 ms
3,440 KB
testcase_21 AC 2 ms
3,420 KB
testcase_22 AC 812 ms
35,960 KB
testcase_23 AC 1,346 ms
35,940 KB
testcase_24 AC 1,019 ms
35,936 KB
testcase_25 AC 1,346 ms
35,884 KB
testcase_26 AC 1 ms
3,524 KB
testcase_27 AC 1 ms
3,468 KB
testcase_28 AC 1,026 ms
35,820 KB
testcase_29 AC 1,201 ms
35,968 KB
testcase_30 AC 1,023 ms
35,896 KB
testcase_31 AC 941 ms
35,960 KB
testcase_32 AC 1,072 ms
35,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define moder (1000000007)
#define pie acos(-1)
#define P std::pair<int,int>
#define prique priority_queue
#define ggr getchar();getchar();return 0;
using namespace std;
int n,d;
vector<int> vec;
signed main(){
	cin>>n>>d;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++)vec.push_back(i*i+j*j);
	}
	sort(vec.begin(),vec.end());
	int ans=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			ans+=upper_bound(vec.begin(),vec.end(),i*i-j*j+d)-lower_bound(vec.begin(),vec.end(),i*i-j*j+d);
		}
	}
	cout<<ans<<endl;
	return 0;
}
0