結果
問題 | No.800 四平方定理 |
ユーザー |
![]() |
提出日時 | 2022-11-06 10:41:31 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 556 bytes |
コンパイル時間 | 1,370 ms |
コンパイル使用メモリ | 165,468 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 01:24:21 |
合計ジャッジ時間 | 6,015 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 RE * 2 |
other | AC * 1 WA * 4 RE * 25 |
ソースコード
#include <bits/stdc++.h> using namespace std; //D=n^2-m^2 , 1 <= n,m <= Nを満たす組み合わせの数え上げ int count(int d,int N){ int c = 0; for(int i=0;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); }