結果

問題 No.800 四平方定理
ユーザー lightninglightning
提出日時 2019-03-17 23:01:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 1,123 bytes
コンパイル時間 2,383 ms
コンパイル使用メモリ 168,500 KB
実行使用メモリ 34,420 KB
最終ジャッジ日時 2023-09-22 09:34:40
合計ジャッジ時間 3,547 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 16 ms
18,344 KB
testcase_11 AC 17 ms
20,616 KB
testcase_12 AC 16 ms
20,464 KB
testcase_13 AC 15 ms
19,136 KB
testcase_14 AC 17 ms
20,472 KB
testcase_15 AC 18 ms
20,304 KB
testcase_16 AC 17 ms
20,656 KB
testcase_17 AC 17 ms
20,460 KB
testcase_18 AC 16 ms
20,556 KB
testcase_19 AC 18 ms
20,404 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 19 ms
20,812 KB
testcase_23 AC 43 ms
34,176 KB
testcase_24 AC 41 ms
34,420 KB
testcase_25 AC 46 ms
34,324 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 41 ms
34,084 KB
testcase_29 AC 43 ms
34,280 KB
testcase_30 AC 40 ms
33,968 KB
testcase_31 AC 38 ms
32,044 KB
testcase_32 AC 42 ms
34,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define TDARRAY(int,a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) {if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a, T b) {if(a>b){a=b;return 1;}return 0;}

int n,d;
vector<int> mp;

int main(){
    cin >> n >> d;
    mp.resize(n*n*2+1,0);
    REP(i,n){
        FOR(j,i,n){
            if(i==j){
                int c = (i+1)*(i+1)+(j+1)*(j+1);
                mp[c]++;
            }else{
                int c = (i+1)*(i+1)+(j+1)*(j+1);
                mp[c]+=2;
            }
        }
    }
    int res = 0;
    REP(i,n){
        REP(j,n){
            int x = d+(i+1)*(i+1)-(j+1)*(j+1);
            if(0<=x&&x<=n*n*2)res+=mp[x];
        }
    }
    put(res);
    return 0;
}

0