結果

問題 No.800 四平方定理
ユーザー yuji9511yuji9511
提出日時 2019-03-18 11:50:55
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 930 bytes
コンパイル時間 1,192 ms
コンパイル使用メモリ 143,476 KB
実行使用メモリ 65,060 KB
最終ジャッジ日時 2023-09-25 05:54:57
合計ジャッジ時間 4,297 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,380 KB
testcase_01 AC 3 ms
4,592 KB
testcase_02 AC 3 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 3 ms
4,788 KB
testcase_07 AC 3 ms
4,420 KB
testcase_08 AC 3 ms
4,764 KB
testcase_09 AC 3 ms
4,632 KB
testcase_10 AC 34 ms
36,292 KB
testcase_11 AC 34 ms
38,180 KB
testcase_12 AC 35 ms
38,208 KB
testcase_13 AC 33 ms
36,124 KB
testcase_14 AC 32 ms
38,156 KB
testcase_15 AC 33 ms
38,168 KB
testcase_16 AC 32 ms
40,224 KB
testcase_17 AC 32 ms
40,228 KB
testcase_18 AC 34 ms
40,392 KB
testcase_19 AC 32 ms
40,248 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 35 ms
40,228 KB
testcase_23 AC 70 ms
64,988 KB
testcase_24 AC 93 ms
65,044 KB
testcase_25 AC 83 ms
65,004 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 70 ms
65,016 KB
testcase_29 AC 82 ms
65,060 KB
testcase_30 AC 68 ms
64,920 KB
testcase_31 AC 68 ms
62,744 KB
testcase_32 AC 68 ms
65,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18 + 7)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
ll cnt[8000010] = {};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,D;
    cin >> N >> D;
    rep(x,1,N+1){
        rep(y,1,N+1){
            cnt[x*x+y*y]++;
        }
    }
    ll ans = 0;
    
    rep(z,1,N+1){
        rep(w,1,N+1){
            ll v = D + w*w - z*z;
            if(v <= 0) continue;
            ans += cnt[v];
        }
    }
    print(ans);


 }
0