結果
問題 | No.800 四平方定理 |
ユーザー |
![]() |
提出日時 | 2021-01-26 01:23:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 96 ms / 2,000 ms |
コード長 | 497 bytes |
コンパイル時間 | 1,445 ms |
コンパイル使用メモリ | 167,056 KB |
実行使用メモリ | 53,760 KB |
最終ジャッジ日時 | 2024-06-23 01:14:30 |
合計ジャッジ時間 | 3,641 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;int cnt1[10000000];int cnt2[10000000];int main(){int n, d; cin >> n >> d;for(int x = 1; x <= n; x++){for(int y = 1; y <= n; y++){cnt1[x*x+y*y]++;}}for(int z = 1; z <= n; z++){for(int w = 1; w <= n; w++){if(-z*z+w*w+d<0) continue;cnt2[-z*z+w*w+d]++;}}int ans = 0;for(int i = 0; i < 1e7; i++){ans += cnt1[i]*cnt2[i];}cout << ans << endl;return 0;}