結果

問題 No.800 四平方定理
ユーザー amesyuamesyu
提出日時 2019-10-05 10:08:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,697 ms / 2,000 ms
コード長 842 bytes
コンパイル時間 1,158 ms
コンパイル使用メモリ 102,196 KB
実行使用メモリ 67,008 KB
最終ジャッジ日時 2024-04-15 11:38:41
合計ジャッジ時間 24,014 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
6,812 KB
testcase_01 AC 21 ms
6,940 KB
testcase_02 AC 15 ms
6,940 KB
testcase_03 AC 17 ms
6,944 KB
testcase_04 AC 15 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,940 KB
testcase_08 AC 12 ms
6,940 KB
testcase_09 AC 22 ms
6,940 KB
testcase_10 AC 750 ms
34,240 KB
testcase_11 AC 832 ms
53,952 KB
testcase_12 AC 870 ms
56,452 KB
testcase_13 AC 673 ms
35,780 KB
testcase_14 AC 739 ms
52,968 KB
testcase_15 AC 868 ms
52,940 KB
testcase_16 AC 751 ms
53,304 KB
testcase_17 AC 748 ms
53,136 KB
testcase_18 AC 947 ms
52,700 KB
testcase_19 AC 940 ms
55,432 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 945 ms
53,500 KB
testcase_23 AC 1,697 ms
66,584 KB
testcase_24 AC 1,431 ms
65,796 KB
testcase_25 AC 1,688 ms
66,364 KB
testcase_26 AC 2 ms
6,944 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 1,421 ms
65,540 KB
testcase_29 AC 1,606 ms
66,980 KB
testcase_30 AC 1,433 ms
67,008 KB
testcase_31 AC 1,316 ms
61,348 KB
testcase_32 AC 1,483 ms
65,788 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