結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-13 06:52:32 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 128 ms / 2,000 ms |
| コード長 | 382 bytes |
| コンパイル時間 | 2,574 ms |
| コンパイル使用メモリ | 192,528 KB |
| 最終ジャッジ日時 | 2025-01-10 10:46:31 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
8 | int n,d; scanf("%d%d",&n,&d);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
int n,d; scanf("%d%d",&n,&d);
vector<int> cnt(2*n*n+1);
for(int x=1;x<=n;x++) for(int y=1;y<=n;y++) cnt[x*x+y*y]++;
int ans=0;
for(int z=1;z<=n;z++) for(int w=1;w<=n;w++) {
int tar=w*w+d-z*z;
if(0<=tar && tar<=2*n*n) ans+=cnt[tar];
}
printf("%d\n",ans);
return 0;
}