QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#687722#7704. Plus Minus Four SquaresdbaumgAC ✓3ms3704kbC++201.3kb2024-10-29 20:49:592024-10-29 20:50:02

Judging History

你现在查看的是最新测评结果

  • [2024-10-29 20:50:02]
  • 评测
  • 测评结果:AC
  • 用时:3ms
  • 内存:3704kb
  • [2024-10-29 20:49:59]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    ll n;
    cin >> n;
    ll ans = 0;
    for (ll a = 0; a * a <= n; a++) {
        for (ll b = 0; b <= a; b++) {
            for (ll c = 0; c <= b; c++) {
                for (ll d = 0; d <= c; d++) {
                    bool x = a != b;
                    bool y = b != c;
                    bool z = c != d;
                    if (a * a + b * b + c * c + d * d == n) ans += 1;
                    if (a * a + b * b + c * c - d * d == n && d > 0 && z) ans += 1;
                    if (a * a + b * b - c * c + d * d == n && c > 0 && y && z) ans += 1;
                    if (a * a + b * b - c * c - d * d == n && c > 0 && d > 0 && y) ans += 1;
                    if (a * a - b * b + c * c + d * d == n && b > 0 && x && y) ans += 1;
                    if (a * a - b * b + c * c - d * d == n && b > 0 && d > 0 && x && y && z) ans += 1;
                    if (a * a - b * b - c * c + d * d == n && b > 0 && c > 0 && x && z) ans += 1;
                    if (a * a - b * b - c * c - d * d == n && b > 0 && c > 0 && d > 0 && x) ans += 1;
                }
            }
        }
    }
    cout << ans;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3564kb

input:

64

output:

12

result:

ok single line: '12'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3704kb

input:

65

output:

10

result:

ok single line: '10'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3656kb

input:

2023

output:

245

result:

ok single line: '245'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3700kb

input:

0

output:

1

result:

ok single line: '1'

Test #5:

score: 0
Accepted
time: 3ms
memory: 3656kb

input:

5000

output:

951

result:

ok single line: '951'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

1024

output:

182

result:

ok single line: '182'

Test #7:

score: 0
Accepted
time: 1ms
memory: 3704kb

input:

2048

output:

355

result:

ok single line: '355'

Test #8:

score: 0
Accepted
time: 2ms
memory: 3664kb

input:

4096

output:

708

result:

ok single line: '708'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3652kb

input:

1

output:

1

result:

ok single line: '1'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

2

output:

1

result:

ok single line: '1'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3660kb

input:

4

output:

2

result:

ok single line: '2'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

3

output:

1

result:

ok single line: '1'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

1111

output:

131

result:

ok single line: '131'