結果

問題 No.800 四平方定理
ユーザー eQeeQe
提出日時 2019-03-18 00:04:59
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 907 bytes
コンパイル時間 1,079 ms
コンパイル使用メモリ 143,260 KB
実行使用メモリ 67,104 KB
最終ジャッジ日時 2023-09-22 16:10:38
合計ジャッジ時間 3,296 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,632 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,772 KB
testcase_07 AC 3 ms
4,408 KB
testcase_08 AC 3 ms
4,768 KB
testcase_09 AC 2 ms
4,552 KB
testcase_10 AC 32 ms
36,128 KB
testcase_11 AC 36 ms
38,144 KB
testcase_12 AC 36 ms
38,188 KB
testcase_13 AC 32 ms
36,368 KB
testcase_14 AC 35 ms
38,144 KB
testcase_15 AC 38 ms
38,160 KB
testcase_16 AC 36 ms
40,200 KB
testcase_17 AC 35 ms
40,264 KB
testcase_18 AC 40 ms
40,236 KB
testcase_19 AC 41 ms
40,300 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 40 ms
40,476 KB
testcase_23 AC 82 ms
66,820 KB
testcase_24 AC 75 ms
66,924 KB
testcase_25 AC 82 ms
66,876 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 75 ms
66,812 KB
testcase_29 AC 78 ms
66,924 KB
testcase_30 AC 75 ms
66,860 KB
testcase_31 AC 68 ms
62,900 KB
testcase_32 AC 76 ms
67,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb(t) push_back(t)
#define pt(num) cout << num << "\n"
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;


ll cnt[10101010];
int main(void) {
    ll N, D;
    cin >> N >> D;
    ll i, j;
    
    for(i=1; i<=N; i++) {
        for(j=1; j<=N; j++) {
            cnt[i*i+j*j]++;
        }
    }
    
    ll ans=0;
    for(i=1; i<=N; i++) {
        for(j=1; j<=N; j++) {
            ll t=i*i+D-j*j;
            if(t>0)
                ans+=cnt[t];
        }
    }
    
    pt(ans);
}
0