結果

問題 No.800 四平方定理
ユーザー Y17Y17
提出日時 2019-03-17 22:16:45
言語 C++11
(gcc 8.5.0)
結果
AC  
実行時間 1,351 ms / 2,000 ms
コード長 533 bytes
コンパイル時間 1,437 ms
使用メモリ 94,880 KB
最終ジャッジ日時 2023-02-11 08:14:55
合計ジャッジ時間 19,136 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 6 ms
4,196 KB
testcase_01 AC 11 ms
5,452 KB
testcase_02 AC 7 ms
4,324 KB
testcase_03 AC 8 ms
4,536 KB
testcase_04 AC 7 ms
4,464 KB
testcase_05 AC 8 ms
4,588 KB
testcase_06 AC 12 ms
5,604 KB
testcase_07 AC 12 ms
5,592 KB
testcase_08 AC 8 ms
4,440 KB
testcase_09 AC 9 ms
4,832 KB
testcase_10 AC 532 ms
48,612 KB
testcase_11 AC 554 ms
52,376 KB
testcase_12 AC 595 ms
54,156 KB
testcase_13 AC 454 ms
44,528 KB
testcase_14 AC 525 ms
50,004 KB
testcase_15 AC 602 ms
53,360 KB
testcase_16 AC 530 ms
50,192 KB
testcase_17 AC 526 ms
48,344 KB
testcase_18 AC 685 ms
58,904 KB
testcase_19 AC 883 ms
82,548 KB
testcase_20 AC 2 ms
3,432 KB
testcase_21 AC 1 ms
3,504 KB
testcase_22 AC 686 ms
56,804 KB
testcase_23 AC 1,351 ms
94,880 KB
testcase_24 AC 1,120 ms
88,756 KB
testcase_25 AC 1,329 ms
93,308 KB
testcase_26 AC 2 ms
3,524 KB
testcase_27 AC 1 ms
3,380 KB
testcase_28 AC 1,221 ms
88,756 KB
testcase_29 AC 1,272 ms
94,368 KB
testcase_30 AC 1,077 ms
86,168 KB
testcase_31 AC 1,035 ms
84,080 KB
testcase_32 AC 1,145 ms
87,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    long long n, d;
    cin >> n >> d;

    long long ans = 0;
    unordered_map<long long, long long> mp;

    for(long long i = 1;i <= n;i++){
        for(long long j = 1;j <= n;j++){
            if(i*i-j*j+d > 0 && i*i-j*j+d <= n*n+n*n){
                mp[i*i-j*j+d]++;
            }
        }
    }

    for(long long i = 1;i <= n;i++){
        for(long long j = 1;j <= n;j++){
            ans += mp[i*i+j*j];
        }
    }


    cout << ans << endl;

    return 0;
}
0