結果

問題 No.800 四平方定理
ユーザー chocopuuchocopuu
提出日時 2019-03-19 07:14:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 1,081 bytes
コンパイル時間 1,559 ms
コンパイル使用メモリ 164,640 KB
実行使用メモリ 67,120 KB
最終ジャッジ日時 2023-10-11 05:00:37
合計ジャッジ時間 5,405 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,732 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 3 ms
4,372 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 3 ms
4,816 KB
testcase_07 AC 3 ms
4,440 KB
testcase_08 AC 4 ms
4,724 KB
testcase_09 AC 3 ms
4,592 KB
testcase_10 AC 40 ms
36,160 KB
testcase_11 AC 44 ms
38,276 KB
testcase_12 AC 46 ms
38,120 KB
testcase_13 AC 38 ms
36,088 KB
testcase_14 AC 41 ms
38,236 KB
testcase_15 AC 46 ms
38,260 KB
testcase_16 AC 44 ms
40,316 KB
testcase_17 AC 43 ms
40,192 KB
testcase_18 AC 48 ms
40,236 KB
testcase_19 AC 49 ms
40,180 KB
testcase_20 AC 2 ms
4,352 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 50 ms
40,260 KB
testcase_23 AC 103 ms
66,828 KB
testcase_24 AC 88 ms
67,072 KB
testcase_25 AC 96 ms
66,796 KB
testcase_26 AC 1 ms
4,352 KB
testcase_27 AC 1 ms
4,356 KB
testcase_28 AC 86 ms
66,816 KB
testcase_29 AC 94 ms
66,864 KB
testcase_30 AC 88 ms
67,120 KB
testcase_31 AC 82 ms
62,808 KB
testcase_32 AC 91 ms
66,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define FOR(i,n) for(int i = 0;i<n;i++)
#define rep(i,s,n) for(int i = s;i<n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const ll MOD=1000000007,INF=1ll<<60;
typedef vector<vint>vvint;

int N,D;
int cnt[2020*2020*2]={};

signed main() {
    IOS();
    cin>>N>>D;
    rep(i,1,N+1){
        rep(j,1,N+1){
            cnt[i*i+j*j]++;
        }
    }
    
    int ans=0;
    rep(i,1,N+1){
        rep(j,1,N+1){
            if(D+i*i-j*j>=0)ans+=cnt[D+i*i-j*j];
        }
    }
    cout<<ans<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}
0