結果

問題 No.800 四平方定理
ユーザー ogingingoginging
提出日時 2019-03-17 21:44:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 703 bytes
コンパイル時間 1,309 ms
コンパイル使用メモリ 145,112 KB
実行使用メモリ 65,436 KB
最終ジャッジ日時 2023-09-22 04:45:59
合計ジャッジ時間 3,768 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
65,296 KB
testcase_01 AC 20 ms
65,240 KB
testcase_02 AC 20 ms
65,372 KB
testcase_03 AC 21 ms
65,192 KB
testcase_04 AC 19 ms
65,276 KB
testcase_05 AC 21 ms
65,436 KB
testcase_06 AC 19 ms
65,168 KB
testcase_07 AC 20 ms
65,224 KB
testcase_08 AC 20 ms
65,288 KB
testcase_09 AC 19 ms
65,188 KB
testcase_10 AC 42 ms
65,336 KB
testcase_11 AC 46 ms
65,228 KB
testcase_12 AC 47 ms
65,424 KB
testcase_13 AC 43 ms
65,264 KB
testcase_14 AC 46 ms
65,388 KB
testcase_15 AC 48 ms
65,352 KB
testcase_16 AC 47 ms
65,328 KB
testcase_17 AC 46 ms
65,344 KB
testcase_18 AC 52 ms
65,220 KB
testcase_19 AC 51 ms
65,328 KB
testcase_20 AC 20 ms
65,380 KB
testcase_21 AC 18 ms
65,320 KB
testcase_22 AC 50 ms
65,328 KB
testcase_23 AC 86 ms
65,120 KB
testcase_24 AC 80 ms
65,220 KB
testcase_25 AC 86 ms
65,240 KB
testcase_26 AC 20 ms
65,340 KB
testcase_27 AC 19 ms
65,156 KB
testcase_28 AC 77 ms
65,208 KB
testcase_29 AC 82 ms
65,120 KB
testcase_30 AC 76 ms
65,196 KB
testcase_31 AC 74 ms
65,376 KB
testcase_32 AC 79 ms
65,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;

int main(){
    ll i,j;
    ll n;
    vector<ll> v(8000080,0);
    cin>>n;
    ll d;
    cin>>d;

    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            v[i*i+j*j]++;
        }
    }
    ll ans=0;
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            ll r=d+i*i-j*j;
            if(r>=0&&r<=8000060){
                ans+=v[r];
            }
        }
    }
    cout<<ans<<endl;
    
    return 0;
}
0