結果

問題 No.800 四平方定理
ユーザー rogi52rogi52
提出日時 2022-08-13 13:51:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 506 bytes
コンパイル時間 2,742 ms
コンパイル使用メモリ 208,568 KB
実行使用メモリ 81,932 KB
最終ジャッジ日時 2023-10-24 22:14:35
合計ジャッジ時間 7,055 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
5,388 KB
testcase_01 AC 37 ms
6,768 KB
testcase_02 AC 25 ms
5,900 KB
testcase_03 AC 28 ms
6,168 KB
testcase_04 AC 23 ms
5,772 KB
testcase_05 AC 28 ms
6,092 KB
testcase_06 AC 45 ms
7,360 KB
testcase_07 AC 32 ms
6,492 KB
testcase_08 AC 46 ms
7,328 KB
testcase_09 AC 41 ms
6,900 KB
testcase_10 TLE -
testcase_11 -- -
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 <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int N,D; cin >> N >> D;
    map<int,int> a, b;
    for(int i = 1; i <= N; i++)
        for(int j = 1; j <= N; j++)
            a[i * i + j * j]++, b[i * i - j * j]++;
    
    int ans = 0;
    for(auto [x, cnt] : a) {
        if(b.count(x - D)) {
            ans += cnt * b[x - D];
        }
    }

    cout << ans << endl;
}
0