結果
| 問題 | 
                            No.800 四平方定理
                             | 
                    
| コンテスト | |
| ユーザー | 
                             tempura_pp
                         | 
                    
| 提出日時 | 2019-03-14 13:50:12 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                RE
                                 
                             
                            
                            (最新)
                                AC
                                 
                             
                            (最初)
                            
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 403 bytes | 
| コンパイル時間 | 1,674 ms | 
| コンパイル使用メモリ | 168,016 KB | 
| 実行使用メモリ | 81,536 KB | 
| 最終ジャッジ日時 | 2024-07-01 19:34:53 | 
| 合計ジャッジ時間 | 9,609 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 22 RE * 8 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
int MAX = 5e6;
int main(){
	int n;
	cin>>n;
	int d;
	cin>>d;
	vector<long long> cnt1(MAX),cnt2(MAX);
	REP(i,1,n+1)REP(j,1,n+1){
		cnt1[i*i+j*j]++;
		if(i*i-j*j+d>0)cnt2[i*i-j*j+d]++;
	}
	long long ans=0;
	rep(i,MAX)ans+=cnt1[i]*cnt2[i];
	cout<<ans<<endl;
	return 0;
}
            
            
            
        
            
tempura_pp