結果

問題 No.800 四平方定理
ユーザー youluoyyouluoy
提出日時 2019-03-17 21:30:31
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 755 bytes
コンパイル時間 1,268 ms
使用メモリ 64,528 KB
最終ジャッジ日時 2023-02-11 04:23:55
合計ジャッジ時間 3,273 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
4,904 KB
testcase_01 AC 2 ms
4,904 KB
testcase_02 AC 2 ms
6,952 KB
testcase_03 AC 2 ms
6,948 KB
testcase_04 AC 2 ms
4,900 KB
testcase_05 AC 2 ms
4,904 KB
testcase_06 AC 3 ms
6,948 KB
testcase_07 AC 2 ms
4,904 KB
testcase_08 AC 3 ms
6,948 KB
testcase_09 AC 2 ms
4,904 KB
testcase_10 AC 20 ms
33,588 KB
testcase_11 AC 20 ms
37,468 KB
testcase_12 AC 20 ms
36,824 KB
testcase_13 AC 17 ms
34,944 KB
testcase_14 AC 18 ms
37,436 KB
testcase_15 AC 19 ms
37,232 KB
testcase_16 AC 18 ms
37,700 KB
testcase_17 AC 19 ms
37,816 KB
testcase_18 AC 21 ms
37,676 KB
testcase_19 AC 22 ms
37,680 KB
testcase_20 AC 2 ms
4,904 KB
testcase_21 AC 2 ms
4,904 KB
testcase_22 AC 22 ms
37,756 KB
testcase_23 AC 54 ms
64,528 KB
testcase_24 AC 52 ms
64,472 KB
testcase_25 AC 55 ms
64,224 KB
testcase_26 AC 1 ms
6,948 KB
testcase_27 AC 1 ms
4,900 KB
testcase_28 AC 52 ms
64,252 KB
testcase_29 AC 55 ms
64,284 KB
testcase_30 AC 51 ms
64,248 KB
testcase_31 AC 44 ms
59,940 KB
testcase_32 AC 52 ms
64,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
#define mk make_pair
#define pb push_back
#define pf push_front
typedef pair<int, int> pii;
#define INF (1 << 30)
#define INFL (1ll << 60ll);
#define mod 1000000007
#define se second
#define fi first

int N, D;
int rakkyo[10000000];

signed main()
{
    cin >> N >> D;
    int ans = 0;
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= N; j++){
            rakkyo[i * i + j * j]++;
        }
    }
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= N; j++){
            int res = i * i + D - j * j;
            if(res > 0){
                ans += rakkyo[res];
            }
        }
    }
    cout << ans << endl;




    return 0;
}

/*



*/
0