結果

問題 No.800 四平方定理
ユーザー kappybarkappybar
提出日時 2020-04-11 22:21:46
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 651 bytes
コンパイル時間 1,588 ms
コンパイル使用メモリ 168,440 KB
実行使用メモリ 65,760 KB
最終ジャッジ日時 2023-10-19 18:31:34
合計ジャッジ時間 4,719 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
65,760 KB
testcase_01 AC 19 ms
65,760 KB
testcase_02 AC 19 ms
65,760 KB
testcase_03 AC 19 ms
65,760 KB
testcase_04 AC 19 ms
65,760 KB
testcase_05 AC 19 ms
65,760 KB
testcase_06 AC 19 ms
65,760 KB
testcase_07 AC 19 ms
65,760 KB
testcase_08 AC 19 ms
65,760 KB
testcase_09 AC 18 ms
65,760 KB
testcase_10 AC 47 ms
65,760 KB
testcase_11 AC 50 ms
65,760 KB
testcase_12 AC 50 ms
65,760 KB
testcase_13 AC 46 ms
65,760 KB
testcase_14 AC 50 ms
65,760 KB
testcase_15 AC 51 ms
65,760 KB
testcase_16 AC 51 ms
65,760 KB
testcase_17 AC 50 ms
65,760 KB
testcase_18 AC 55 ms
65,760 KB
testcase_19 AC 55 ms
65,760 KB
testcase_20 AC 19 ms
65,760 KB
testcase_21 AC 19 ms
65,760 KB
testcase_22 AC 56 ms
65,760 KB
testcase_23 AC 96 ms
65,760 KB
testcase_24 AC 87 ms
65,760 KB
testcase_25 AC 97 ms
65,760 KB
testcase_26 AC 18 ms
65,760 KB
testcase_27 AC 18 ms
65,760 KB
testcase_28 AC 89 ms
65,760 KB
testcase_29 AC 92 ms
65,760 KB
testcase_30 AC 87 ms
65,760 KB
testcase_31 AC 81 ms
65,760 KB
testcase_32 AC 91 ms
65,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll =  long long ;
using P = pair<int,int> ;
const int INF = 1e9;
const int MOD = 1000000007;
const ll MX = 8000005;

int main(){
    ll n,d;
    cin >> n >> d;
    vector<ll> a(MX,0);
    for(ll i=1;i<=n;i++){
        ll res = i * i;
        for(ll j=1;j<=n;j++){
            a[res+j*j] ++;
        }
    }
    ll ans = 0;
    for(ll i=1;i<=n;i++){
        ll res = i * i;
        for(ll j=1;j<=n;j++){
            ll c = res + d - j*j;
            if(c < 0 || c >= MX) continue;
            ans += a[c];
        }
    }
    cout << ans << endl;
    return 0;
}
0