結果

問題 No.800 四平方定理
ユーザー hamrayhamray
提出日時 2019-03-17 22:10:12
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,335 ms / 2,000 ms
コード長 669 bytes
コンパイル時間 693 ms
コンパイル使用メモリ 73,900 KB
実行使用メモリ 37,668 KB
最終ジャッジ日時 2023-09-22 06:56:36
合計ジャッジ時間 18,076 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
4,376 KB
testcase_01 AC 16 ms
4,380 KB
testcase_02 AC 11 ms
4,376 KB
testcase_03 AC 13 ms
4,380 KB
testcase_04 AC 12 ms
4,376 KB
testcase_05 AC 13 ms
4,376 KB
testcase_06 AC 19 ms
4,380 KB
testcase_07 AC 17 ms
4,380 KB
testcase_08 AC 12 ms
4,376 KB
testcase_09 AC 16 ms
4,376 KB
testcase_10 AC 600 ms
19,992 KB
testcase_11 AC 620 ms
36,816 KB
testcase_12 AC 693 ms
36,764 KB
testcase_13 AC 497 ms
20,024 KB
testcase_14 AC 543 ms
36,636 KB
testcase_15 AC 682 ms
37,080 KB
testcase_16 AC 546 ms
36,440 KB
testcase_17 AC 545 ms
36,320 KB
testcase_18 AC 794 ms
37,144 KB
testcase_19 AC 795 ms
37,100 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 795 ms
36,488 KB
testcase_23 AC 1,335 ms
36,820 KB
testcase_24 AC 1,013 ms
36,884 KB
testcase_25 AC 1,331 ms
36,904 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1,011 ms
37,668 KB
testcase_29 AC 1,183 ms
36,956 KB
testcase_30 AC 1,006 ms
36,664 KB
testcase_31 AC 940 ms
35,956 KB
testcase_32 AC 1,074 ms
37,332 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