結果

問題 No.800 四平方定理
ユーザー amesyuamesyu
提出日時 2019-10-05 10:06:30
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,686 ms / 2,000 ms
コード長 842 bytes
コンパイル時間 949 ms
コンパイル使用メモリ 90,996 KB
実行使用メモリ 68,776 KB
最終ジャッジ日時 2024-04-15 11:32:22
合計ジャッジ時間 23,622 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,816 KB
testcase_01 AC 21 ms
6,944 KB
testcase_02 AC 14 ms
6,944 KB
testcase_03 AC 16 ms
6,944 KB
testcase_04 AC 14 ms
6,940 KB
testcase_05 AC 17 ms
6,940 KB
testcase_06 AC 24 ms
6,940 KB
testcase_07 AC 17 ms
6,944 KB
testcase_08 AC 12 ms
6,940 KB
testcase_09 AC 21 ms
6,944 KB
testcase_10 AC 746 ms
34,432 KB
testcase_11 AC 795 ms
52,884 KB
testcase_12 AC 835 ms
54,692 KB
testcase_13 AC 675 ms
35,616 KB
testcase_14 AC 739 ms
54,772 KB
testcase_15 AC 855 ms
55,180 KB
testcase_16 AC 752 ms
54,200 KB
testcase_17 AC 743 ms
53,820 KB
testcase_18 AC 926 ms
53,544 KB
testcase_19 AC 925 ms
53,568 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 1 ms
6,940 KB
testcase_22 AC 919 ms
52,776 KB
testcase_23 AC 1,686 ms
67,108 KB
testcase_24 AC 1,420 ms
66,972 KB
testcase_25 AC 1,654 ms
68,776 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 1,410 ms
66,124 KB
testcase_29 AC 1,552 ms
65,568 KB
testcase_30 AC 1,429 ms
67,380 KB
testcase_31 AC 1,297 ms
62,208 KB
testcase_32 AC 1,451 ms
65,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
using namespace std;
int main() {
    long long n, m;
    long long t = 0;
    long long ans = 0;
    cin >> n >> m;
    vector<long long> xy;
    vector<long long> wz;
    for(long long i=1;i<n+1;i++) {
        for(long long j=1;j<n+1;j++) {
            xy.push_back(i*i + j*j);
            wz.push_back(i*i - j*j + m);
            t+=1;
        }
    }
    sort(wz.begin(), wz.end());
    for(int i=0;i<xy.size();i++) {
        long long low = distance(wz.begin(), lower_bound(wz.begin(), wz.end(), xy[i]));
        long long up = distance(wz.begin(), upper_bound(wz.begin(), wz.end(), xy[i]));
        ans += up-low;
    }
    cout << ans <<  endl;
}
0