結果
| 問題 | 
                            No.800 四平方定理
                             | 
                    
| コンテスト | |
| ユーザー | 
                             pockyny
                         | 
                    
| 提出日時 | 2019-03-18 03:43:56 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 59 ms / 2,000 ms | 
| コード長 | 320 bytes | 
| コンパイル時間 | 506 ms | 
| コンパイル使用メモリ | 65,800 KB | 
| 実行使用メモリ | 64,560 KB | 
| 最終ジャッジ日時 | 2024-07-08 10:10:22 | 
| 合計ジャッジ時間 | 1,949 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 30 | 
ソースコード
#include <iostream>
using namespace std;
long long cnt[10000000] = {},n,d,ans = 0;
int main(){
	int i,j;
	cin >> n >> d;
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			cnt[i*i+j*j]++;
		}
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			if(d - i*i + j*j<=0) continue;
			ans += cnt[d-i*i+j*j];
		}
	}
	cout << ans << endl;
}
            
            
            
        
            
pockyny