結果

問題 No.800 四平方定理
ユーザー Y17Y17
提出日時 2019-03-17 22:16:45
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 533 bytes
コンパイル時間 3,049 ms
コンパイル使用メモリ 150,696 KB
実行使用メモリ 94,968 KB
最終ジャッジ日時 2023-09-22 07:19:32
合計ジャッジ時間 31,206 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
4,380 KB
testcase_01 AC 13 ms
5,580 KB
testcase_02 AC 8 ms
4,492 KB
testcase_03 AC 8 ms
4,564 KB
testcase_04 AC 7 ms
4,520 KB
testcase_05 AC 8 ms
4,452 KB
testcase_06 AC 12 ms
5,564 KB
testcase_07 AC 12 ms
5,572 KB
testcase_08 AC 8 ms
4,380 KB
testcase_09 AC 10 ms
4,644 KB
testcase_10 AC 878 ms
48,740 KB
testcase_11 AC 938 ms
52,372 KB
testcase_12 AC 998 ms
54,132 KB
testcase_13 AC 758 ms
44,676 KB
testcase_14 AC 872 ms
50,056 KB
testcase_15 AC 996 ms
53,292 KB
testcase_16 AC 866 ms
50,216 KB
testcase_17 AC 853 ms
48,460 KB
testcase_18 AC 1,188 ms
58,836 KB
testcase_19 AC 1,346 ms
82,456 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1,189 ms
56,720 KB
testcase_23 TLE -
testcase_24 AC 1,918 ms
88,680 KB
testcase_25 TLE -
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1,867 ms
88,820 KB
testcase_29 TLE -
testcase_30 AC 1,892 ms
86,188 KB
testcase_31 AC 1,685 ms
83,956 KB
testcase_32 AC 1,839 ms
87,304 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