結果
問題 | No.800 四平方定理 |
ユーザー |
![]() |
提出日時 | 2022-11-06 10:44:30 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 593 bytes |
コンパイル時間 | 1,549 ms |
コンパイル使用メモリ | 167,292 KB |
実行使用メモリ | 13,888 KB |
最終ジャッジ日時 | 2024-07-20 01:28:28 |
合計ジャッジ時間 | 5,382 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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) - i && (d/i) + i <= 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); }