結果

問題 No.800 四平方定理
ユーザー face4
提出日時 2019-03-17 22:02:59
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 513 bytes
コンパイル時間 504 ms
コンパイル使用メモリ 73,072 KB
実行使用メモリ 65,872 KB
最終ジャッジ日時 2024-07-07 23:02:04
合計ジャッジ時間 2,881 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

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 < 8000001; i++){
        if(i-d+4000000 > 8000009)  break;
        ans += l[i]*r[i-d+4000000];
    }
    cout << ans << endl;
    return 0;
}
0