結果

問題 No.800 四平方定理
コンテスト
ユーザー vjudge1
提出日時 2026-02-05 19:27:43
言語 C++17(gcc12)
(gcc 12.4.0 + boost 1.89.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 1,157 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,828 ms
コンパイル使用メモリ 202,956 KB
実行使用メモリ 18,964 KB
最終ジャッジ日時 2026-02-05 19:27:49
合計ジャッジ時間 5,709 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
//????????? 
#define ztyroy_AK_statement_0205
#define hyc_qcz_jmr_baoyouwo_AC

#define int long long
#define made_by_ztyroy return 0;

#define rep(i,f,s) for(int i=f;i<=s;i++)
#define fep(i,f,s) for(int i=f;i<s;i++)
#define per(i,f,s) for(int i=f;i>=s;i--)
#define pef(i,f,s) for(int i=f;i>s;i--)

namespace FastIO{
	template <typename T> inline void read(T &x){
		x=0;
		T f=1;
		T c=getchar();
		for(;!isdigit(c);c=getchar()){
			if(c=='-'){
				f=-1;
			}
		}
		for(;isdigit(c);c=getchar()){
			x=(x<<1)+(x<<3)+(c^48);
		}
		x*=f;
	}
	template <typename T> void print(T x){
		if(x<0){
			x=-x;
			putchar('-'); 
		}
		if(x>9){
			print(x/10);
		}
		putchar((x%10)^48);
	}
}

using namespace std;
using namespace FastIO;
int n,tar,ans;
short is[8000005];
signed main(){
	ztyroy_AK_statement_0205
	hyc_qcz_jmr_baoyouwo_AC
//	freopen("alive1.in","r",stdin);
//	freopen("alive.in","r",stdin);
//	freopen("alive.out","w",stdout);
	read(n);
	read(tar);
	rep(a,1,n){
		rep(b,1,n){
			is[a*a+b*b]++;
		}
	}
	rep(c,1,n){
		rep(d,1,n){
			if(tar+d*d-c*c<0){
				continue;
			} 
			ans+=is[tar+d*d-c*c];
		}
	}
	print(ans);
	made_by_ztyroy
}
0