結果
| 問題 | No.800 四平方定理 |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2026-02-05 19:26:33 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 71 ms / 2,000 ms |
| コード長 | 1,005 bytes |
| 記録 | |
| コンパイル時間 | 1,694 ms |
| コンパイル使用メモリ | 184,380 KB |
| 実行使用メモリ | 67,012 KB |
| 最終ジャッジ日時 | 2026-02-05 19:26:38 |
| 合計ジャッジ時間 | 3,980 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
template<typename T> inline void read(T &x){
T s = 0; int st = 1; char c = getchar();
while(c < '0' || c > '9'){(c == '-') && (st = -1); c = getchar();}
while(c >= '0' && c <= '9'){s = (s <<3) +(s << 1) + (c ^ 48); c = getchar();}
x = s * st;
}
template<typename T, typename... Args> inline void read(T &x, Args &...args){
read(x); read(args...);
}
template<typename T> inline void write(T x){
if(x < 0) putchar('-'), x = -x;
if(x > 9) write(x / 10);
putchar(x % 10 + 48);
}
#define LL long long
const int N = 2e3 + 5, M = 9e6 + 5;
LL f[M];
int main(){
// freopen("alive.in", "r", stdin);
// freopen("alive.out", "w", stdout);
// cerr <<sizeof(f) / 1024.0 / 1024;
int n, k;
read(n, k);
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= n; ++j){
++f[i * i + j * j];
}
}
LL ans = 0;
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= n; ++j){
if(i * i + k <= j * j) break;
ans += f[i * i + k - j * j];
}
}
write(ans);
return 0;
}
vjudge1