QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#331931#7704. Plus Minus Four Squarescry#AC ✓47ms3884kbC++141.0kb2024-02-19 00:10:522024-02-19 00:10:52

Judging History

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

  • [2024-02-19 00:10:52]
  • 评测
  • 测评结果:AC
  • 用时:47ms
  • 内存:3884kb
  • [2024-02-19 00:10:52]
  • 提交

answer

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

const int MAX = 15000;
ll dp[5][MAX + 1][71];

int n;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	vector<int> valid;
	valid.push_back(0);
	for(int i = 1; i * i <= n; i++) {
		valid.push_back(i * i);
		valid.push_back(-i * i);
	}
	sort(valid.begin(), valid.end());
	int ans = 0;
	for(int i = 0; i < valid.size(); i++) {
		for(int j = i; j < valid.size(); j++) {
			for(int k = j; k < valid.size(); k++) {
				for(int l = k; l < valid.size(); l++) {
					if((valid[i] && (valid[i] == -valid[j] || valid[i] == -valid[k] || valid[i] == -valid[l])) || (valid[j] && (valid[j] == -valid[k] || valid[j] == -valid[l])) || (valid[k] && valid[k] == -valid[l])) {
						continue;
					}
					if(valid[i] < 0 && abs(valid[i]) > max({abs(valid[j]), abs(valid[k]), abs(valid[l])})) {
						continue;
					}
					if(valid[i] + valid[j] + valid[k] + valid[l] == n) {
						ans++;
					}
				}
			}
		}
	}
	cout << ans << "\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

64

output:

12

result:

ok single line: '12'

Test #2:

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

input:

65

output:

10

result:

ok single line: '10'

Test #3:

score: 0
Accepted
time: 8ms
memory: 3884kb

input:

2023

output:

245

result:

ok single line: '245'

Test #4:

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

input:

0

output:

1

result:

ok single line: '1'

Test #5:

score: 0
Accepted
time: 47ms
memory: 3640kb

input:

5000

output:

951

result:

ok single line: '951'

Test #6:

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

input:

1024

output:

182

result:

ok single line: '182'

Test #7:

score: 0
Accepted
time: 9ms
memory: 3612kb

input:

2048

output:

355

result:

ok single line: '355'

Test #8:

score: 0
Accepted
time: 33ms
memory: 3636kb

input:

4096

output:

708

result:

ok single line: '708'

Test #9:

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

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: 3848kb

input:

4

output:

2

result:

ok single line: '2'

Test #12:

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

input:

3

output:

1

result:

ok single line: '1'

Test #13:

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

input:

1111

output:

131

result:

ok single line: '131'