結果

問題 No.800 四平方定理
ユーザー outlineoutline
提出日時 2020-03-28 18:05:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,517 bytes
コンパイル時間 1,072 ms
コンパイル使用メモリ 111,960 KB
実行使用メモリ 440,748 KB
最終ジャッジ日時 2023-08-30 18:05:15
合計ジャッジ時間 30,690 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
7,620 KB
testcase_01 AC 13 ms
11,164 KB
testcase_02 AC 9 ms
8,840 KB
testcase_03 AC 11 ms
9,512 KB
testcase_04 AC 10 ms
8,544 KB
testcase_05 AC 11 ms
9,312 KB
testcase_06 AC 17 ms
12,636 KB
testcase_07 AC 12 ms
10,308 KB
testcase_08 AC 16 ms
12,968 KB
testcase_09 AC 14 ms
11,580 KB
testcase_10 AC 984 ms
219,632 KB
testcase_11 AC 1,034 ms
246,416 KB
testcase_12 AC 1,057 ms
242,216 KB
testcase_13 AC 947 ms
229,864 KB
testcase_14 AC 1,007 ms
246,504 KB
testcase_15 AC 1,094 ms
244,884 KB
testcase_16 AC 1,030 ms
249,076 KB
testcase_17 AC 1,043 ms
249,040 KB
testcase_18 AC 1,173 ms
248,008 KB
testcase_19 AC 1,189 ms
248,532 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1,156 ms
249,052 KB
testcase_23 TLE -
testcase_24 AC 1,938 ms
440,712 KB
testcase_25 TLE -
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1,897 ms
438,412 KB
testcase_29 TLE -
testcase_30 AC 1,926 ms
438,876 KB
testcase_31 AC 1,880 ms
408,340 KB
testcase_32 AC 1,951 ms
440,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, d;
    cin >> n >> d;
    int ub = n * n * 2;
    vector<vector<ll>> cnt(ub + 1, vector<ll>(2, 0));
    for(int x = 1; x <= n; ++x){
        for(int y = 1; y <= n; ++y){
            int foo = x * x + y * y;
            ++cnt[foo][0];
            int bar = x * x - y * y + d;
            if(bar <= 0 || bar > ub)    continue;
            ++cnt[bar][1];
        }
    }
    ll ans = 0;
    for(int i = 1; i <= ub; ++i)    ans += cnt[i][0] * cnt[i][1];
    cout << ans << endl;
}
0