結果

問題 No.800 四平方定理
ユーザー sinsincoscossinsincoscos
提出日時 2019-03-17 21:42:24
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 420 bytes
コンパイル時間 748 ms
コンパイル使用メモリ 78,468 KB
実行使用メモリ 75,828 KB
最終ジャッジ日時 2023-09-22 04:41:41
合計ジャッジ時間 28,125 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
5,140 KB
testcase_01 AC 18 ms
6,004 KB
testcase_02 AC 12 ms
5,056 KB
testcase_03 AC 14 ms
5,116 KB
testcase_04 AC 12 ms
5,084 KB
testcase_05 AC 14 ms
4,980 KB
testcase_06 AC 23 ms
6,608 KB
testcase_07 AC 16 ms
5,728 KB
testcase_08 AC 24 ms
6,548 KB
testcase_09 AC 22 ms
6,448 KB
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 TLE -
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <unordered_map>
using namespace std;
typedef long long ll;
int N,D;
int main(){
    cin >> N >> D;
    unordered_map<int,ll> m1,m2;
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            m1[i*i+j*j]++;
            m2[i*i-j*j]++;
        }
    }
    ll ans = 0;
    for(auto x:m1){
        if(m2.count(D-x.first)) ans += x.second*m2[D-x.first];
    }
    cout << ans << endl;
}
0