結果

問題 No.800 四平方定理
ユーザー HyadoHyado
提出日時 2019-03-18 09:12:44
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 652 bytes
コンパイル時間 1,501 ms
コンパイル使用メモリ 167,008 KB
実行使用メモリ 65,720 KB
最終ジャッジ日時 2023-09-24 21:49:56
合計ジャッジ時間 4,799 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 3 ms
4,404 KB
testcase_10 AC 41 ms
33,808 KB
testcase_11 AC 45 ms
37,892 KB
testcase_12 AC 47 ms
37,200 KB
testcase_13 AC 43 ms
35,412 KB
testcase_14 AC 46 ms
37,904 KB
testcase_15 AC 52 ms
37,452 KB
testcase_16 AC 47 ms
38,096 KB
testcase_17 AC 49 ms
38,056 KB
testcase_18 AC 56 ms
37,924 KB
testcase_19 AC 53 ms
38,172 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 53 ms
38,056 KB
testcase_23 AC 115 ms
65,720 KB
testcase_24 AC 101 ms
65,520 KB
testcase_25 AC 111 ms
65,188 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 97 ms
65,196 KB
testcase_29 AC 103 ms
65,344 KB
testcase_30 AC 106 ms
65,216 KB
testcase_31 AC 94 ms
61,000 KB
testcase_32 AC 107 ms
65,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main (){
    int n,d,ans=0;
    cin >> n >> d;

    vector<int> xy(2*n*n+1,0);
    vector<int> zw(2*n*n+1,0);
    //メモリを使って左辺、右辺がある値になる場合の個数を記憶
        
    for(int x=1;x<=n;x++){
        for(int y=1;y<=n;y++){
            xy.at(x*x+y*y-1)++;
        }
    }
    
    for(int w=1;w<=n;w++){
        for(int z=1;z<=n;z++){
            if((w*w-z*z+d) <= (2*n*n) && 0 <= w*w-z*z+d-1){
            zw.at(w*w-z*z+d-1)++;
            }
        }
    }

    for(int i=0;i<2*n*n;i++){
        ans += xy.at(i)*zw.at(i);
    }
    
    cout << ans << endl;
}
0