結果

問題 No.800 四平方定理
ユーザー vjudge1vjudge1
提出日時 2024-10-04 16:28:41
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 986 bytes
コンパイル時間 1,721 ms
コンパイル使用メモリ 168,280 KB
実行使用メモリ 34,388 KB
最終ジャッジ日時 2024-10-04 16:28:45
合計ジャッジ時間 3,039 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(i,j,k) for(int i=(j);i<=(k);++i)
#define NFOR(i,j,k) for(int i=(j);i>=(k);--i)
#define mkp make_pair
#define fst first
#define sec second
#define inl inline
#define pb push_back
#define el_phy_kongroo return 0
using namespace std;
typedef long long ll;
typedef double db;
typedef unsigned int ui;
typedef pair< int,int > pii;
inline int read()
{
	int s=0,w=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar();}
	while(ch>='0'&&ch<='9') {s=(s<<1)+(s<<3)+ch-'0',ch=getchar();}
	return s*w;
}
void file()
{
	freopen("alive.in","r",stdin);
	freopen("alive.out","w",stdout);
}
void teltim(int x)
{
	clock_t c1=0;
	if(x) c1=clock();
	else cerr<<endl<<clock()-c1<<"ms"<<endl;
}
const int N=2005;

int n,k;
int nm1[N*N*2];

int main()
{
	//file();
	n=read();k=read();
	FOR(i,1,n) FOR(j,1,n) nm1[i*i+j*j]++;
	ll ans=0;
	FOR(i,1,n) FOR(j,1,n) 
	{
		int x=i*i+k-j*j;
		if(x>=0) ans+=nm1[x];
	}
	printf("%lld",ans);
	el_phy_kongroo;
}

0