結果

問題 No.800 四平方定理
ユーザー ShibuyapShibuyap
提出日時 2019-10-14 15:03:30
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 738 bytes
コンパイル時間 1,617 ms
コンパイル使用メモリ 164,972 KB
実行使用メモリ 55,300 KB
最終ジャッジ日時 2023-08-25 15:26:03
合計ジャッジ時間 4,284 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
5,528 KB
testcase_01 AC 10 ms
5,876 KB
testcase_02 AC 9 ms
5,652 KB
testcase_03 AC 10 ms
5,908 KB
testcase_04 AC 9 ms
5,596 KB
testcase_05 AC 11 ms
5,628 KB
testcase_06 AC 11 ms
5,740 KB
testcase_07 AC 10 ms
6,068 KB
testcase_08 AC 10 ms
6,072 KB
testcase_09 AC 9 ms
5,728 KB
testcase_10 AC 30 ms
29,928 KB
testcase_11 AC 34 ms
32,012 KB
testcase_12 AC 37 ms
34,032 KB
testcase_13 AC 32 ms
29,932 KB
testcase_14 AC 33 ms
32,064 KB
testcase_15 AC 36 ms
34,032 KB
testcase_16 AC 34 ms
32,044 KB
testcase_17 AC 34 ms
31,992 KB
testcase_18 AC 37 ms
36,152 KB
testcase_19 AC 38 ms
36,156 KB
testcase_20 AC 10 ms
5,424 KB
testcase_21 AC 9 ms
5,400 KB
testcase_22 AC 39 ms
36,228 KB
testcase_23 AC 83 ms
55,300 KB
testcase_24 AC 79 ms
50,908 KB
testcase_25 AC 86 ms
54,976 KB
testcase_26 AC 9 ms
5,368 KB
testcase_27 AC 10 ms
7,420 KB
testcase_28 AC 75 ms
50,836 KB
testcase_29 AC 81 ms
52,912 KB
testcase_30 AC 75 ms
50,900 KB
testcase_31 AC 69 ms
50,496 KB
testcase_32 AC 78 ms
50,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_XY 8000005

int xy[MAX_XY];
int zw[MAX_XY];
int main() {
    int n, d;
    cin >> n >> d;
    
    srep(i,1,n+1){
        srep(j,1,n+1){
            xy[i*i + j*j]++;
        }
    }

    srep(i,1,n+1){
        srep(j,1,n+1){
            int tmp = d - (i + j) * (i - j);
            if(0 <= tmp)zw[tmp]++;
        }
    }

    int ans = 0;

    rep(i,MAX_XY){
        ans += xy[i] * zw[i];
    }

    cout << ans << endl;
    return 0;
}
 
 
 
0