結果

問題 No.800 四平方定理
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2019-06-17 19:16:03
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 1,702 bytes
コンパイル時間 546 ms
コンパイル使用メモリ 73,316 KB
実行使用メモリ 34,612 KB
最終ジャッジ日時 2023-08-18 19:52:36
合計ジャッジ時間 2,927 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 29 ms
18,524 KB
testcase_11 AC 33 ms
20,588 KB
testcase_12 AC 34 ms
20,216 KB
testcase_13 AC 29 ms
19,228 KB
testcase_14 AC 30 ms
20,468 KB
testcase_15 AC 32 ms
20,396 KB
testcase_16 AC 31 ms
20,836 KB
testcase_17 AC 29 ms
20,732 KB
testcase_18 AC 36 ms
20,756 KB
testcase_19 AC 36 ms
20,404 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 34 ms
20,528 KB
testcase_23 AC 82 ms
34,424 KB
testcase_24 AC 78 ms
34,308 KB
testcase_25 AC 80 ms
34,224 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 77 ms
34,312 KB
testcase_29 AC 80 ms
34,260 KB
testcase_30 AC 78 ms
34,612 KB
testcase_31 AC 69 ms
32,108 KB
testcase_32 AC 77 ms
34,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#include <tuple>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
#define MOD 1000000007
#define INF 1000000000
#define LLINF 4000000000000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
void input() {}
template<typename... R> void input(int& f, R&... r) { scanf("%d", &f); input(r...); }
template<typename... R> void input(double& f, R&... r) { scanf("%lf", &f); input(r...); }
template<typename... R> void input(ll& f, R&... r) { scanf("%lld", &f); input(r...); }
template<typename... R> void input(char& f, R&... r) { scanf("%c", &f); input(r...); }
template<typename... R> void input(string& f, R&... r) { cin >> f; input(r...); }
template<typename T, typename... R> void input(vector<T>& f, R&... r) { REP(i, f.size())input(f[i]); input(r...); }
#pragma endregion

int main() {
    int N, D; input(N, D);
    vector<int> cnt(N*N * 2 + 1, 0);
    int ans = 0;
    REP(x, N) {
        REP(y, N) {
            int a = (x + 1) * (x + 1) + (y + 1) * (y + 1);
            cnt[a]++;
        }
    }
    REP(z, N) {
        REP(w, N) {
            int b = D + (w + 1) * (w + 1) - (z + 1) * (z + 1);
            if (b >= 0 && b <= N * N * 2) ans += cnt[b];
        }
    }
    cout << ans << endl;
    getchar(); getchar();
}
0