結果

問題 No.800 四平方定理
ユーザー ahe100ahe100
提出日時 2019-03-17 22:38:19
言語 C++11
(gcc 8.5.0)
結果
AC  
実行時間 207 ms / 2,000 ms
コード長 1,008 bytes
コンパイル時間 439 ms
使用メモリ 126,952 KB
最終ジャッジ日時 2023-02-11 09:40:42
合計ジャッジ時間 4,731 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
4,632 KB
testcase_01 AC 3 ms
5,704 KB
testcase_02 AC 2 ms
5,092 KB
testcase_03 AC 3 ms
5,228 KB
testcase_04 AC 2 ms
4,992 KB
testcase_05 AC 3 ms
5,328 KB
testcase_06 AC 3 ms
6,196 KB
testcase_07 AC 3 ms
5,624 KB
testcase_08 AC 4 ms
6,252 KB
testcase_09 AC 3 ms
5,948 KB
testcase_10 AC 97 ms
64,452 KB
testcase_11 AC 110 ms
72,132 KB
testcase_12 AC 109 ms
70,992 KB
testcase_13 AC 102 ms
67,356 KB
testcase_14 AC 110 ms
72,176 KB
testcase_15 AC 109 ms
71,760 KB
testcase_16 AC 116 ms
72,816 KB
testcase_17 AC 111 ms
72,804 KB
testcase_18 AC 111 ms
72,592 KB
testcase_19 AC 112 ms
72,692 KB
testcase_20 AC 1 ms
3,436 KB
testcase_21 AC 1 ms
3,388 KB
testcase_22 AC 113 ms
72,944 KB
testcase_23 AC 207 ms
126,932 KB
testcase_24 AC 205 ms
126,892 KB
testcase_25 AC 206 ms
126,536 KB
testcase_26 AC 1 ms
3,484 KB
testcase_27 AC 1 ms
3,516 KB
testcase_28 AC 205 ms
126,420 KB
testcase_29 AC 207 ms
126,724 KB
testcase_30 AC 205 ms
126,488 KB
testcase_31 AC 189 ms
117,860 KB
testcase_32 AC 204 ms
126,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll mod = 1e9+7;
//LLONG_MIN

/*

*/

ll n,d,ans=0,p[8000010],m[8000010];
// map<ll,ll> p,m;

int main(void){
	cin>>n>>d;
	// reg(x,1,n){
	// 	reg(y,1,n){
	// 		reg(z,1,n){
	// 			reg(w,1,n){
	// 				if(x*x + y*y + z*z == w*w +d){
	// 					printf("%d,%d,%d,%d,\n",x,y,z,w);
	// 				}
	// 			}
	// 		}
	// 	}
	// }
	reg(x,1,n){
		reg(y,1,n){
			p[x*x + y*y]++;
			m[x*x - y*y+4000000]++;
		}
	}
	reg(i,2,2*n*n){
		if(i-d+4000000<=8000000)ans+=p[i]*m[i-d+4000000];
	}
	cout<<ans<<endl;
	return 0;
}
0