結果
問題 | No.800 四平方定理 |
ユーザー |
|
提出日時 | 2021-03-14 11:41:35 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 196 ms / 2,000 ms |
コード長 | 443 bytes |
コンパイル時間 | 2,529 ms |
コンパイル使用メモリ | 191,192 KB |
最終ジャッジ日時 | 2025-01-19 16:17:45 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include<bits/stdc++.h>using namespace std;using ll = long long;ll xy[2001*4001];int main(){ll n,d;cin >> n >> d;for(ll x=1;x <= n;x++){for(ll y=1;y <= n;y++){xy[x*x + y*y]++;}}ll ans = 0;for(ll w=1;w <= n;w++){for(ll z=1;z <= n;z++){ll X = w*w - z*z + d;if(X >= 0) ans += xy[X];}}cout << ans << endl;return 0;}