結果
問題 | No.800 四平方定理 |
ユーザー |
![]() |
提出日時 | 2020-05-15 09:17:49 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 58 ms / 2,000 ms |
コード長 | 699 bytes |
コンパイル時間 | 1,612 ms |
コンパイル使用メモリ | 167,908 KB |
実行使用メモリ | 34,560 KB |
最終ジャッジ日時 | 2024-09-17 15:29:11 |
合計ジャッジ時間 | 3,235 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=(0);i<(n);i++) using namespace std; typedef long long ll; template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; } int main(){ cin.tie(0); ios::sync_with_stdio(false); int n, d; cin >> n >> d; int max_n = max((n + 1) * (n + 1) + d, 2 * (n + 1) * (n + 1)) + 1; vector<int> v(max_n, 0); rep(z, n) rep(w, n){ int a = (w + 1) * (w + 1) - (z + 1) * (z + 1) + d; if(a >= 0) v[a]++; } int ans = 0; rep(x, n) rep(y, n){ int a = (x + 1) * (x + 1) + (y + 1) * (y + 1); ans += v[a]; } cout << ans << endl; }