QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#714584 | #7704. Plus Minus Four Squares | rand123 | WA | 1ms | 3800kb | C++14 | 2.7kb | 2024-11-06 00:39:56 | 2024-11-06 00:39:57 |
Judging History
answer
#include <bits/stdc++.h>
#define pii pair<int,int>
#define pb push_back
#define yes "YES"
#define no "NO"
#define ll long long
#define MOD 1000000007
#define all(x) x.begin(),x.end()
#define MOD2 998244353
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(int cas){
ll n;
cin>>n;
ll res = 0;
for (int i = 0; i<=(int)sqrt(n); i++){
for (int sub = 0; sub < i; sub++){
for (int add = 0; add < sub; add++){
ll curr = i*i - sub*sub + add*add;
if (curr < n){
ll diff = abs(n - curr);
ll sq = sqrtl(diff);
if (sq*sq==diff && sq <= add) res++;
}
else{
ll diff = abs(n - curr);
ll sq = sqrtl(diff);
if (sq*sq==diff && sq < add) res++;
}
}
for (int sub2 = 0; sub2 <= sub; sub2++){
ll curr = i*i - sub2*sub2 - sub*sub;
if (curr < n){
ll diff = abs(n - curr);
ll sq = sqrtl(diff);
if (sq*sq==diff && sq < sub2) res++;
}
else{
ll diff = abs(n - curr);
ll sq = sqrtl(diff);
if (sq*sq==diff && sq <= sub2) res++;
}
}
}
for (int add = 0; add <= i; add++){
for (int add2 = 0; add2 <= add; add2++){
ll curr = i*i + add*add + add2*add2;
if (curr < n){
ll diff = abs(n - curr);
ll sq = sqrtl(diff);
if (sq*sq==diff && sq <= add2) res++;
}
else{
ll diff = abs(n - curr);
ll sq = sqrtl(diff);
if (sq*sq==diff && sq < add2) res++;
}
}
for (int sub2 = 0; sub2 < add; sub2++){
ll curr = i*i - sub2*sub2 + add*add;
if (curr < n){
ll diff = abs(n - curr);
ll sq = sqrtl(diff);
if (sq*sq==diff && sq < sub2) res++;
}
else{
ll diff = abs(n - curr);
ll sq = sqrtl(diff);
if (sq*sq==diff && sq <= sub2) res++;
}
}
}
}
cout<<res<<'\n';
}
int main(){
int t=1;
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
//cin>>t;
for (int i = 1; i<=t; i++){
solve(i);
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3668kb
input:
64
output:
12
result:
ok single line: '12'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
65
output:
10
result:
ok single line: '10'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3792kb
input:
2023
output:
245
result:
ok single line: '245'
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3800kb
input:
0
output:
0
result:
wrong answer 1st lines differ - expected: '1', found: '0'