結果
問題 | No.800 四平方定理 |
ユーザー |
|
提出日時 | 2020-04-11 22:21:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 87 ms / 2,000 ms |
コード長 | 651 bytes |
コンパイル時間 | 1,569 ms |
コンパイル使用メモリ | 168,776 KB |
実行使用メモリ | 65,792 KB |
最終ジャッジ日時 | 2024-09-19 14:50:15 |
合計ジャッジ時間 | 4,385 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;i++) using namespace std; using ll = long long ; using P = pair<int,int> ; const int INF = 1e9; const int MOD = 1000000007; const ll MX = 8000005; int main(){ ll n,d; cin >> n >> d; vector<ll> a(MX,0); for(ll i=1;i<=n;i++){ ll res = i * i; for(ll j=1;j<=n;j++){ a[res+j*j] ++; } } ll ans = 0; for(ll i=1;i<=n;i++){ ll res = i * i; for(ll j=1;j<=n;j++){ ll c = res + d - j*j; if(c < 0 || c >= MX) continue; ans += a[c]; } } cout << ans << endl; return 0; }