結果

問題 No.800 四平方定理
ユーザー face4
提出日時 2019-03-17 21:58:20
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 465 bytes
コンパイル時間 663 ms
コンパイル使用メモリ 72,960 KB
実行使用メモリ 65,792 KB
最終ジャッジ日時 2024-07-07 22:38:31
合計ジャッジ時間 4,944 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;

vector<int> l(8000010), r(8000010);

int main(){
    int n;
    ll d;
    cin >> n >> d;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            l[i*i+j*j]++;
            r[4000000+i*i-j*j]++;
        }
    }
    ll ans = 0;
    for(int i = 0; i < 4000001; i++){
        ans += l[i]*r[i-d+4000000];
    }
    cout << ans << endl;
    return 0;
}
0