結果
| 問題 | 
                            No.800 四平方定理
                             | 
                    
| コンテスト | |
| ユーザー | 
                             pppppppoipoi
                         | 
                    
| 提出日時 | 2019-04-16 23:07:20 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                RE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 552 bytes | 
| コンパイル時間 | 545 ms | 
| コンパイル使用メモリ | 69,896 KB | 
| 実行使用メモリ | 65,716 KB | 
| 最終ジャッジ日時 | 2024-09-22 08:24:41 | 
| 合計ジャッジ時間 | 2,805 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 RE * 1 | 
| other | AC * 28 RE * 2 | 
ソースコード
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
    int n,d;
    ll ans = 0;
    cin >> n >> d;
    vector<int> a(2*n*n+10),b(2*n*n+10);
    
    for(int x = 1;x <= n;x++){
        for(int y = 1;y <= n;y++){
            a[x*x+y*y]++;
        }
    }
    
    for(int w = 1;w <= n;w++){
        for(int z = 1;z <= n;z++){
            if(w*w-z*z+d < 0) continue;
            b[w*w-z*z+d]++;
        }
    }
    for(int i = 1;i <= 2*n*n;i++){
        ans += (ll)a[i]*b[i];
    }
    cout << ans << endl;
}
            
            
            
        
            
pppppppoipoi