結果

問題 No.800 四平方定理
ユーザー ahe100ahe100
提出日時 2019-03-17 22:38:19
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 151 ms / 2,000 ms
コード長 1,008 bytes
コンパイル時間 514 ms
コンパイル使用メモリ 72,252 KB
実行使用メモリ 128,568 KB
最終ジャッジ日時 2023-09-22 08:31:02
合計ジャッジ時間 3,989 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,392 KB
testcase_01 AC 5 ms
11,488 KB
testcase_02 AC 3 ms
7,404 KB
testcase_03 AC 3 ms
7,684 KB
testcase_04 AC 3 ms
7,464 KB
testcase_05 AC 4 ms
7,544 KB
testcase_06 AC 5 ms
11,532 KB
testcase_07 AC 3 ms
9,448 KB
testcase_08 AC 5 ms
11,708 KB
testcase_09 AC 4 ms
11,812 KB
testcase_10 AC 72 ms
68,852 KB
testcase_11 AC 76 ms
77,068 KB
testcase_12 AC 75 ms
77,096 KB
testcase_13 AC 74 ms
73,148 KB
testcase_14 AC 78 ms
77,160 KB
testcase_15 AC 78 ms
77,032 KB
testcase_16 AC 80 ms
77,032 KB
testcase_17 AC 82 ms
77,312 KB
testcase_18 AC 79 ms
77,268 KB
testcase_19 AC 78 ms
77,096 KB
testcase_20 AC 2 ms
7,416 KB
testcase_21 AC 3 ms
7,396 KB
testcase_22 AC 79 ms
77,096 KB
testcase_23 AC 151 ms
128,568 KB
testcase_24 AC 146 ms
128,232 KB
testcase_25 AC 148 ms
128,256 KB
testcase_26 AC 3 ms
7,420 KB
testcase_27 AC 3 ms
7,416 KB
testcase_28 AC 148 ms
128,060 KB
testcase_29 AC 150 ms
128,204 KB
testcase_30 AC 151 ms
128,108 KB
testcase_31 AC 138 ms
122,232 KB
testcase_32 AC 148 ms
128,460 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