結果

問題 No.800 四平方定理
ユーザー ugis_progugis_prog
提出日時 2019-03-17 22:14:19
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 547 bytes
コンパイル時間 1,718 ms
コンパイル使用メモリ 78,000 KB
実行使用メモリ 164,776 KB
最終ジャッジ日時 2023-09-22 07:12:06
合計ジャッジ時間 24,987 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
4,380 KB
testcase_01 AC 15 ms
5,800 KB
testcase_02 AC 12 ms
5,476 KB
testcase_03 AC 13 ms
5,528 KB
testcase_04 AC 9 ms
4,628 KB
testcase_05 AC 12 ms
5,448 KB
testcase_06 AC 17 ms
5,868 KB
testcase_07 AC 14 ms
5,544 KB
testcase_08 AC 19 ms
6,192 KB
testcase_09 AC 15 ms
5,596 KB
testcase_10 AC 925 ms
58,596 KB
testcase_11 AC 1,225 ms
82,536 KB
testcase_12 AC 1,146 ms
82,660 KB
testcase_13 AC 1,100 ms
82,524 KB
testcase_14 AC 1,187 ms
82,552 KB
testcase_15 AC 1,137 ms
82,460 KB
testcase_16 AC 1,201 ms
82,512 KB
testcase_17 AC 1,209 ms
82,528 KB
testcase_18 AC 1,172 ms
82,664 KB
testcase_19 AC 1,154 ms
82,468 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1,181 ms
82,512 KB
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<unordered_map>
using namespace std;

int main(){
    long N,D;
    cin >> N >> D;

    vector<long> sq;
    unordered_map<int,long> sqsum; 
    for(long i=1;i<=N;i++) sq.emplace_back(i*i);
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            sqsum[sq[i]+sq[j]]++;
        }
    }

    long ans = 0;
    for(long x=1;x<=N;x++){
        for(long w=1;w<=N;w++){
            long c = w*w - x*x + D;
            ans += sqsum[c];
        }
    }

    cout << ans << endl;
}
0