結果

問題 No.800 四平方定理
ユーザー hamrayhamray
提出日時 2019-03-17 22:10:12
言語 C++11
(gcc 8.5.0)
結果
AC  
実行時間 1,384 ms / 2,000 ms
コード長 669 bytes
コンパイル時間 509 ms
使用メモリ 36,044 KB
最終ジャッジ日時 2023-02-11 07:48:35
合計ジャッジ時間 18,593 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 8 ms
6,952 KB
testcase_01 AC 16 ms
4,904 KB
testcase_02 AC 11 ms
4,900 KB
testcase_03 AC 12 ms
6,948 KB
testcase_04 AC 12 ms
4,900 KB
testcase_05 AC 14 ms
4,904 KB
testcase_06 AC 18 ms
4,904 KB
testcase_07 AC 17 ms
6,952 KB
testcase_08 AC 12 ms
4,904 KB
testcase_09 AC 16 ms
6,948 KB
testcase_10 AC 598 ms
19,608 KB
testcase_11 AC 644 ms
35,892 KB
testcase_12 AC 704 ms
35,900 KB
testcase_13 AC 482 ms
19,524 KB
testcase_14 AC 552 ms
35,892 KB
testcase_15 AC 701 ms
35,880 KB
testcase_16 AC 549 ms
35,988 KB
testcase_17 AC 560 ms
35,892 KB
testcase_18 AC 828 ms
35,956 KB
testcase_19 AC 818 ms
36,044 KB
testcase_20 AC 2 ms
4,904 KB
testcase_21 AC 1 ms
4,904 KB
testcase_22 AC 807 ms
35,844 KB
testcase_23 AC 1,384 ms
35,884 KB
testcase_24 AC 1,047 ms
35,892 KB
testcase_25 AC 1,366 ms
35,852 KB
testcase_26 AC 1 ms
6,948 KB
testcase_27 AC 2 ms
6,952 KB
testcase_28 AC 1,022 ms
35,976 KB
testcase_29 AC 1,220 ms
35,904 KB
testcase_30 AC 1,019 ms
35,940 KB
testcase_31 AC 943 ms
35,856 KB
testcase_32 AC 1,107 ms
35,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <cstring>
#include <functional>
#include <tuple>
using namespace std;
using ll = long long;
vector<ll> v;
int main()
{
    ll N, D; cin >> N >> D;
    
    for(ll i=1; i<=N; ++i){
        for(ll j=1; j<=N; ++j){
            v.push_back(i*i+j*j);
        }
    }
    sort(v.begin(), v.end());
    
    ll ans=0;
    for(int i=1; i<=N; ++i){
        for(int j=1; j<=N; ++j){
            ans += upper_bound(v.begin(), v.end(), D+i*i-j*j) - lower_bound(v.begin(), v.end(), D+i*i-j*j);
        }
    }
    cout << ans << endl;
    
    
    return 0;
}
0