結果

問題 No.800 四平方定理
ユーザー lightninglightning
提出日時 2019-03-17 22:03:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,788 bytes
コンパイル時間 1,932 ms
コンパイル使用メモリ 172,224 KB
実行使用メモリ 61,036 KB
最終ジャッジ日時 2023-09-22 06:20:39
合計ジャッジ時間 23,168 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
8,760 KB
testcase_01 AC 18 ms
4,504 KB
testcase_02 AC 14 ms
4,380 KB
testcase_03 AC 14 ms
4,456 KB
testcase_04 AC 13 ms
4,376 KB
testcase_05 AC 15 ms
4,380 KB
testcase_06 AC 22 ms
4,968 KB
testcase_07 AC 18 ms
4,420 KB
testcase_08 AC 17 ms
4,796 KB
testcase_09 AC 20 ms
4,632 KB
testcase_10 AC 1,462 ms
30,556 KB
testcase_11 AC 1,481 ms
33,912 KB
testcase_12 AC 1,635 ms
33,336 KB
testcase_13 AC 1,227 ms
31,660 KB
testcase_14 AC 1,332 ms
33,712 KB
testcase_15 AC 1,655 ms
33,616 KB
testcase_16 AC 1,334 ms
34,324 KB
testcase_17 AC 1,381 ms
33,988 KB
testcase_18 AC 1,919 ms
33,952 KB
testcase_19 AC 1,848 ms
33,908 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1,959 ms
34,080 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

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> e;
map<int,int> mp;

int main(){
    cin >> n >> d;
    //e.resize(n*n);
    REP(i,n){
        FOR(j,i,n){
            if(i==j){
                int c = (i+1)*(i+1)+(j+1)*(j+1);
                //e[i*n+j] = c;
                auto itr = mp.find(c);
                if(itr!=mp.end()){
                    mp[c]++;
                }else{
                    mp[c]=1;
                }
            }else{
                int c = (i+1)*(i+1)+(j+1)*(j+1);
                //e[i*n+j] = c;
                auto itr = mp.find(c);
                if(itr!=mp.end()){
                    mp[c]+=2;
                }else{
                    mp[c]=2;
                }
            }
            /*int c = (i+1)*(i+1)+(j+1)*(j+1);
            //e[i*n+j] = c;
            auto itr = mp.find(c);
            if(itr!=mp.end()){
                mp[c]++;
            }else{
                mp[c]=1;
             }*/
        }
    }
    ll res = 0;
    REP(i,n){
        REP(j,n){
            int x = d+(i+1)*(i+1)-(j+1)*(j+1);
            auto itr = mp.find(x);
            if(itr!=mp.end()){
                res+=mp[x];
            }
        }
    }
    put(res);
    return 0;
}

0