結果
| 問題 | 
                            No.800 四平方定理
                             | 
                    
| コンテスト | |
| ユーザー | 
                             hiro71687k
                         | 
                    
| 提出日時 | 2023-03-15 14:53:46 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 119 ms / 2,000 ms | 
| コード長 | 772 bytes | 
| コンパイル時間 | 3,815 ms | 
| コンパイル使用メモリ | 249,872 KB | 
| 最終ジャッジ日時 | 2025-02-11 11:36:49 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 30 | 
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=int;
using ld=long double;
ld pie=3.141592653589793;
ll inf=444444444;
ll mod=1000000007;
int main(){
    ll n,d;
    cin >> n >> d;
    vector<ll>memo(n*n+n*n+2,0);
    for (ll i = 1; i <=n; i++)
    {
        for (ll j = 1; j <=n; j++)
        {
            memo[i*i+j*j]+=1;
        }
    }
    vector<ll>memo2(n*n+n*n+2+d,0);
    for (ll i = 1; i <=n; i++)
    {
        for (ll j = 1; j <=n; j++)
        {
            if (i*i-j*j+d<=0)
            {
                continue;
            }
            memo2[i*i-j*j+d]+=1;
        }
    }
    ll ans=0;
    for (ll i = 1; i < memo.size(); i++)
    {
        ans+=memo[i]*memo2[i];
    }
    cout << ans << endl;
}
            
            
            
        
            
hiro71687k