QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#647120 | #7704. Plus Minus Four Squares | enze114514 | WA | 2ms | 3792kb | C++20 | 4.9kb | 2024-10-17 11:50:14 | 2024-10-17 11:50:16 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define pb push_back
const ld pi = 3.14159265358979323846;
const ll INF = 1e18;
template<typename T>
T chmax(T a, T b) {
return a > b ? a : b;
}
template<typename T>
T chmin(T a, T b) {
return a > b ? b : a;
}
void solve() {
int n;
cin >> n;
int qwq = 0;
map<vector<int>, int> mp;
for(int i = 0; i * i <= n; i++){
for(int j = 0; j <= i; j++){
for(int k = 0; k <= j; k++){
for(int l = 0; l <= k; l++){
if(i * i == j * j && j * j == k * k && k * k == l * l){
if(i * i + j * j + k * k + l * l == n){
mp[{i, j, k, l}] = 1;
}
}
else if(i * i == j * j && j * j == k * k){
if(i * i + j * j + k * k + l * l == n){
mp[{i, j, k, l}] = 1;
}
if(i * i + j * j - k * k - l * l == n){
mp[{i, j, k, l}] = 1;
}
}
else if(j * j == k * k && k * k == l * l){
if(i * i - j * j - k * k - l * l == n){
mp[{i, j, k, l}] = 1;
}
if(i * i + j * j + k * k + l * l == n){
mp[{i, j, k, l}] = 1;
}
}
else if(i * i == j * j){
if(i * i + j * j + k * k + l * l == n){
mp[{i, j, k, l}] = 1;
}
if(i * i + j * j - k * k + l * l == n){
mp[{i, j, k, l}] = 1;
}
if(i * i + j * j - k * k - l * l == n){
mp[{i, j, k, l}] = 1;
}
if(i * i + j * j + k * k - l * l == n){
mp[{i, j, k, l}] = 1;
}
}
else if(j * j == k * k){
if(i * i + j * j + k * k + l * l == n){
mp[{i, j, k, l}] = 1;
}
if(i * i + j * j + k * k - l * l == n){
mp[{i, j, k, l}] = 1;
}
if(i * i - j * j - k * k + l * l == n){
mp[{i, j, k, l}] = 1;
}
if(i * i - j * j - k * k - l * l == n){
mp[{i, j, k, l}] = 1;
}
}
else if(k * k == l * l){
if(i * i + j * j + k * k + l * l == n){
mp[{i, j, k, l}] = 1;
}
if(i * i - j * j + k * k + l * l == n){
mp[{i, j, k, l}] = 1;
}
if(i * i + j * j - k * k - l * l == n){
mp[{i, j, k, l}] = 1;
}
if(i * i - j * j - k * k - l * l == n){
mp[{i, j, k, l}] = 1;
}
}
else{
if(i * i + j * j + k * k + l * l == n){
mp[{i, j, k, l}] = 1;
}
if(i * i - j * j - k * k + l * l == n){
mp[{i, j, k, l}] = 1;
}
if(i * i - j * j + k * k - l * l == n){
mp[{i, j, k, l}] = 1;
}
if(i * i + j * j - k * k - l * l == n){
mp[{i, j, k, l}] = 1;
}
if(i * i + j * j + k * k - l * l == n){
mp[{i, j, k, l}] = 1;
}
if(i * i + j * j - k * k + l * l == n){
mp[{i, j, k, l}] = 1;
}
if(i * i - j * j + k * k + l * l == n){
mp[{i, j, k, l}] = 1;
}
if(i * i - j * j - k * k - l * l == n){
mp[{i, j, k, l}] = 1;
}
}
}
}
}
}
cout << mp.size() << endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3620kb
input:
64
output:
12
result:
ok single line: '12'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
65
output:
10
result:
ok single line: '10'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
2023
output:
245
result:
ok single line: '245'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
0
output:
1
result:
ok single line: '1'
Test #5:
score: -100
Wrong Answer
time: 2ms
memory: 3716kb
input:
5000
output:
1000
result:
wrong answer 1st lines differ - expected: '951', found: '1000'