結果
問題 | No.800 四平方定理 |
ユーザー |
![]() |
提出日時 | 2019-03-18 17:16:31 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 46 ms / 2,000 ms |
コード長 | 430 bytes |
コンパイル時間 | 1,216 ms |
コンパイル使用メモリ | 157,832 KB |
実行使用メモリ | 34,176 KB |
最終ジャッジ日時 | 2024-07-18 11:53:31 |
合計ジャッジ時間 | 2,559 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h>typedef long long ll;#define FOR(i,a,b) for(int i=(a);i<(b);i++)#define REP(i,a) FOR(i,0,a)using namespace std;const int MAX_N=2000;int cnt[MAX_N*MAX_N*2+1];int N,D;int main(){cin>>N>>D;REP(i,N){REP(j,N){cnt[(i+1)*(i+1)+(j+1)*(j+1)]++;}}ll ans=0;REP(i,N){REP(j,N){int x=(i+1)*(i+1)-(j+1)*(j+1)+D;if(0<=x && x<=N*N*2){ans+=cnt[x];}}}cout<<ans<<endl;}