結果

問題 No.800 四平方定理
ユーザー ugis_progugis_prog
提出日時 2019-03-17 22:32:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,736 ms / 2,000 ms
コード長 534 bytes
コンパイル時間 696 ms
コンパイル使用メモリ 85,492 KB
実行使用メモリ 94,964 KB
最終ジャッジ日時 2023-09-22 08:15:03
合計ジャッジ時間 23,124 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
4,376 KB
testcase_01 AC 11 ms
5,508 KB
testcase_02 AC 7 ms
4,376 KB
testcase_03 AC 8 ms
4,428 KB
testcase_04 AC 7 ms
4,468 KB
testcase_05 AC 8 ms
4,512 KB
testcase_06 AC 13 ms
5,568 KB
testcase_07 AC 12 ms
5,580 KB
testcase_08 AC 7 ms
4,376 KB
testcase_09 AC 10 ms
4,724 KB
testcase_10 AC 579 ms
48,916 KB
testcase_11 AC 680 ms
52,604 KB
testcase_12 AC 763 ms
54,144 KB
testcase_13 AC 548 ms
44,328 KB
testcase_14 AC 697 ms
49,936 KB
testcase_15 AC 737 ms
53,300 KB
testcase_16 AC 747 ms
50,328 KB
testcase_17 AC 820 ms
48,484 KB
testcase_18 AC 904 ms
59,028 KB
testcase_19 AC 936 ms
82,584 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 0 ms
4,376 KB
testcase_22 AC 796 ms
56,788 KB
testcase_23 AC 1,736 ms
94,964 KB
testcase_24 AC 1,518 ms
88,744 KB
testcase_25 AC 1,703 ms
93,308 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1,621 ms
88,744 KB
testcase_29 AC 1,611 ms
94,288 KB
testcase_30 AC 1,482 ms
86,188 KB
testcase_31 AC 1,396 ms
84,144 KB
testcase_32 AC 1,579 ms
87,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

    for(int y=1;y<=N;y++){
        for(int z=1;z<=N;z++){
            sqsum[y*y+z*z]++;
        }
    }

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

    cout << ans << endl;
}
0