結果
問題 | No.800 四平方定理 |
ユーザー |
![]() |
提出日時 | 2019-03-17 21:35:18 |
言語 | C++11 (gcc 8.5.0) |
結果 |
AC
|
実行時間 | 37 ms / 2,000 ms |
コード長 | 2,575 bytes |
コンパイル時間 | 991 ms |
使用メモリ | 42,600 KB |
最終ジャッジ日時 | 2023-02-11 04:44:54 |
合計ジャッジ時間 | 2,886 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,904 KB |
testcase_01 | AC | 3 ms
4,900 KB |
testcase_02 | AC | 2 ms
4,900 KB |
testcase_03 | AC | 2 ms
4,900 KB |
testcase_04 | AC | 2 ms
6,948 KB |
testcase_05 | AC | 2 ms
4,900 KB |
testcase_06 | AC | 2 ms
4,900 KB |
testcase_07 | AC | 2 ms
4,908 KB |
testcase_08 | AC | 2 ms
6,948 KB |
testcase_09 | AC | 2 ms
4,904 KB |
testcase_10 | AC | 20 ms
36,236 KB |
testcase_11 | AC | 20 ms
37,444 KB |
testcase_12 | AC | 20 ms
36,804 KB |
testcase_13 | AC | 18 ms
36,248 KB |
testcase_14 | AC | 20 ms
37,308 KB |
testcase_15 | AC | 20 ms
37,188 KB |
testcase_16 | AC | 19 ms
37,784 KB |
testcase_17 | AC | 21 ms
37,776 KB |
testcase_18 | AC | 23 ms
37,700 KB |
testcase_19 | AC | 21 ms
37,576 KB |
testcase_20 | AC | 1 ms
6,948 KB |
testcase_21 | AC | 2 ms
4,904 KB |
testcase_22 | AC | 23 ms
37,800 KB |
testcase_23 | AC | 35 ms
42,560 KB |
testcase_24 | AC | 33 ms
42,516 KB |
testcase_25 | AC | 36 ms
42,516 KB |
testcase_26 | AC | 1 ms
4,900 KB |
testcase_27 | AC | 1 ms
4,900 KB |
testcase_28 | AC | 34 ms
42,548 KB |
testcase_29 | AC | 34 ms
42,568 KB |
testcase_30 | AC | 34 ms
42,600 KB |
testcase_31 | AC | 31 ms
42,456 KB |
testcase_32 | AC | 37 ms
42,496 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #define DEBUG_MODE #define endl '\n' #ifdef DEBUG_MODE #define DEBUG(X) debug_func(X, #X) #define DEBUG_ENDL endl << flush #define DEBUG_SEPARATOR_LINE cout<<"=================\n" #else #define DEBUG(X) 0 #define DEBUG_ENDL 0 #define DEBUG_SEPARATOR_LINE 0 #endif #define ALL(V) (V).begin(), (V).end() #define ALLR(V) (V).rbegin(), (V).rend() #define DEBUG_ENDL_S(S) ((S).size() ? "\n" : "") << flush; template <typename T> using V = vector<T>; template <typename T> using VV = V<V<T>>; template <typename T, typename U> using P = pair<T, U>; using ll = int64_t; using PLL = P<ll, ll>; template <typename T> const T& var_min(const T &t) { return t; } template <typename T> const T& var_max(const T &t) { return t; } template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); } template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); } template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); } template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); } void debug_func_preffix(const string &s) { if(s.size()) cout << s << " = "; } template <typename T> void debug_func(const T &t, const string &s = "") { debug_func_preffix(s); cout << t << DEBUG_ENDL_S(s); } template <typename T, typename U> void debug_func(const P<T, U> &p, const string &s = "") { debug_func_preffix(s); cout << "("; debug_func(p.first); cout << ", "; debug_func(p.second); cout << ")" << DEBUG_ENDL_S(s); } template <typename T> void debug_func(const V<T> &v, const string &s = "") { for(ll i = 0; i < v.size(); i++) { string t = s + "[" + to_string(i) + "]"; debug_func(v[i], t); } } void init_io() { cin.tie(0); ios_base::sync_with_stdio(false); cout << fixed << setprecision(30); } const ll maxs = 2000 * 2000 + 1e6; ll cnt[maxs + 10]; int main() { init_io(); ll N, D; cin >> N >> D; for(ll y = 1; y <= N; y++) { for(ll z = 1; z <= N; z++) { if(y * y + z * z < maxs) cnt[y * y + z * z]++; } } ll ans = 0; for(ll x = 1; x <= N; x++) { for(ll w = 1; w <= N; w++) { ll rv = w * w - x * x + D; if(rv < 0) continue; if(rv >= maxs) continue; ans += cnt[rv]; } } cout << ans << endl; return 0; }