結果

問題 No.800 四平方定理
ユーザー polyomino_24polyomino_24
提出日時 2019-03-18 15:23:29
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,386 bytes
コンパイル時間 917 ms
コンパイル使用メモリ 98,996 KB
実行使用メモリ 77,560 KB
最終ジャッジ日時 2023-09-25 12:34:11
合計ジャッジ時間 8,226 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
4,832 KB
testcase_01 AC 29 ms
5,900 KB
testcase_02 AC 20 ms
5,276 KB
testcase_03 AC 22 ms
5,484 KB
testcase_04 AC 19 ms
5,180 KB
testcase_05 AC 22 ms
5,340 KB
testcase_06 AC 36 ms
6,716 KB
testcase_07 AC 25 ms
5,932 KB
testcase_08 AC 24 ms
6,628 KB
testcase_09 AC 31 ms
6,108 KB
testcase_10 TLE -
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#define show(...) cerr << #__VA_ARGS__ << " = ",debug(__VA_ARGS__);
using namespace std;
using ll = long long;
using pii = pair<int,int>;
template<typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a){
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os, vector<T> v){
    for(auto x:v)os << x << ' ';
    return os;
}
void debug(){cerr << '\n';}
template<typename H, typename... T>
void debug(H a, T... b){
    cerr << a;
    if(sizeof...(b))cerr << ", ";
    debug(b...);
}
int main(){
    ll n,d;
    cin >> n >> d;
    map<ll,ll>mp;
    for(ll i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            mp[i*i-j*j]++;
        }
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(mp.count(i*i+j*j-d))ans += mp[i*i+j*j-d];
        }
    }
    cout << ans << endl;
}
0