結果

問題 No.800 四平方定理
ユーザー siro53siro53
提出日時 2019-09-30 02:33:30
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 1,230 bytes
コンパイル時間 1,743 ms
コンパイル使用メモリ 164,664 KB
実行使用メモリ 81,464 KB
最終ジャッジ日時 2024-04-14 07:41:44
合計ジャッジ時間 4,723 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
81,440 KB
testcase_01 AC 24 ms
81,324 KB
testcase_02 AC 24 ms
81,212 KB
testcase_03 AC 25 ms
81,412 KB
testcase_04 AC 23 ms
81,272 KB
testcase_05 AC 24 ms
81,408 KB
testcase_06 AC 24 ms
81,348 KB
testcase_07 AC 24 ms
81,424 KB
testcase_08 AC 24 ms
81,416 KB
testcase_09 AC 24 ms
81,432 KB
testcase_10 AC 57 ms
81,372 KB
testcase_11 AC 61 ms
81,432 KB
testcase_12 AC 63 ms
81,280 KB
testcase_13 AC 54 ms
81,356 KB
testcase_14 AC 55 ms
81,352 KB
testcase_15 AC 63 ms
81,324 KB
testcase_16 AC 56 ms
81,388 KB
testcase_17 AC 57 ms
81,388 KB
testcase_18 AC 68 ms
81,328 KB
testcase_19 AC 69 ms
81,300 KB
testcase_20 AC 24 ms
81,280 KB
testcase_21 AC 23 ms
81,308 KB
testcase_22 AC 70 ms
81,392 KB
testcase_23 AC 111 ms
81,384 KB
testcase_24 AC 100 ms
81,352 KB
testcase_25 AC 113 ms
81,280 KB
testcase_26 AC 24 ms
81,212 KB
testcase_27 AC 24 ms
81,416 KB
testcase_28 AC 100 ms
81,384 KB
testcase_29 AC 107 ms
81,360 KB
testcase_30 AC 97 ms
81,464 KB
testcase_31 AC 93 ms
81,296 KB
testcase_32 AC 103 ms
81,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

vector<int> hoge(10000100);
vector<int> huga(10000100);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, d;
    cin >> n >> d;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            hoge[i * i + j * j]++;
            int tmp = i * i - j * j + d;
            if (tmp >= 2 && tmp <= 2 * n * n)
            {
                huga[tmp]++;
            }
        }
    }
    ll ans = 0;
    for (int i = 2; i <= 2 * n * n; i++)
    {
        ans += (ll)hoge[i] * huga[i];
    }
    cout << ans << endl;
}
0