結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
rieaaddlreiuu
|
| 提出日時 | 2022-11-06 10:43:11 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 593 bytes |
| コンパイル時間 | 1,491 ms |
| コンパイル使用メモリ | 165,964 KB |
| 実行使用メモリ | 10,624 KB |
| 最終ジャッジ日時 | 2024-07-20 01:27:09 |
| 合計ジャッジ時間 | 5,590 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | WA * 10 TLE * 1 -- * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
//D=n^2-m^2 , 1 <= n,m <= Nを満たす組み合わせの数え上げ
int count(int d,int N){
if(d < 0){
d = -d;
}
int c = 0;
for(int i=1;i*i<d;i++){
if(d % i != 0) continue;
if(i % 2 != (d/i) % 2) continue;
if(2 <= (d/i) - d && (d/i) + d <= N){
c++;
}
}
return c;
}
int main(){
int N,D;
int c = 0;
scanf("%d %d",&N,&D);
for(int a=1;a<=N;a++){
for(int b=1;b<=N;b++){
c += count(D - a*a - b*b,N);
}
}
printf("%d",c);
}
rieaaddlreiuu