結果

問題 No.800 四平方定理
ユーザー kaagekaage
提出日時 2019-03-17 22:16:33
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,313 ms / 2,000 ms
コード長 679 bytes
コンパイル時間 1,376 ms
コンパイル使用メモリ 149,956 KB
実行使用メモリ 37,380 KB
最終ジャッジ日時 2023-09-22 07:17:43
合計ジャッジ時間 18,266 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
4,380 KB
testcase_01 AC 16 ms
4,380 KB
testcase_02 AC 12 ms
4,380 KB
testcase_03 AC 12 ms
4,376 KB
testcase_04 AC 12 ms
4,376 KB
testcase_05 AC 13 ms
4,380 KB
testcase_06 AC 17 ms
4,376 KB
testcase_07 AC 17 ms
4,376 KB
testcase_08 AC 12 ms
4,380 KB
testcase_09 AC 15 ms
4,380 KB
testcase_10 AC 593 ms
19,704 KB
testcase_11 AC 602 ms
36,148 KB
testcase_12 AC 672 ms
37,180 KB
testcase_13 AC 486 ms
21,140 KB
testcase_14 AC 526 ms
36,620 KB
testcase_15 AC 663 ms
36,168 KB
testcase_16 AC 528 ms
36,816 KB
testcase_17 AC 533 ms
36,684 KB
testcase_18 AC 760 ms
36,876 KB
testcase_19 AC 766 ms
36,560 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 772 ms
36,120 KB
testcase_23 AC 1,305 ms
36,328 KB
testcase_24 AC 991 ms
36,852 KB
testcase_25 AC 1,313 ms
37,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 990 ms
36,288 KB
testcase_29 AC 1,162 ms
36,740 KB
testcase_30 AC 984 ms
37,232 KB
testcase_31 AC 908 ms
36,864 KB
testcase_32 AC 1,038 ms
35,868 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