結果
| 問題 | No.800 四平方定理 |
| コンテスト | |
| ユーザー |
lumefflux
|
| 提出日時 | 2019-03-18 00:45:59 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 508 bytes |
| 記録 | |
| コンパイル時間 | 587 ms |
| コンパイル使用メモリ | 79,872 KB |
| 実行使用メモリ | 23,168 KB |
| 最終ジャッジ日時 | 2026-06-07 08:22:58 |
| 合計ジャッジ時間 | 4,071 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 30 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:24:13: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
24 | ans += c[p[i]+p[j]];
| ~~~~^~~~~~~~~~~~~~~
main.cpp:22:9: note: 'ans' was declared here
22 | int ans;
| ^~~
ソースコード
#include <iostream>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;
int main(){
long N, D;
cin >> N >> D;
int p[2001];
int c[8000001];
REP(i, 1, N + 1){
p[i] = i*i;
}
REP(i, 1, N + 1)REP(j, 1, N + 1){
int s = p[i] - p[j] + D;
if (s >= 1) {
c[s] += 1;
}
}
int ans;
REP(i, 1, 2001)REP(j, 1, 2001){
ans += c[p[i]+p[j]];
}
cout << ans << endl ;
}
lumefflux