Submission #72184328


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
//#define int long long
//const int mod=;

int n;
int ans;
int p[10000007];

signed main() {
	
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	
	cin >> n;
	for (int i = 1; i * i <= n; i++) {
		int g = n - i * i;
		for (int k = 1; k < i && k * k <= g; k++) {
			if (p[i * i + k * k] == 0) ans++;
			if (p[i * i + k * k] == 1) ans--;
			p[i * i + k * k] ++;
		}
	}
	cout << ans << endl;
	for (int i = 1; i <= n; i++) {
		if (p[i] == 1) cout << i << " ";
	}
	return 0;
}

Submission Info

Submission Time
Task C - 2026
User KDL_ANIPLEX
Language C++23 (Clang 21.1.0)
Score 300
Code Size 553 Byte
Status AC
Exec Time 136 ms
Memory 46488 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 18
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 02_corner_00.txt, 02_corner_01.txt, 02_corner_02.txt, 02_corner_03.txt, 02_corner_04.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 2872 KiB
00_sample_01.txt AC 1 ms 2924 KiB
00_sample_02.txt AC 1 ms 2924 KiB
01_random_00.txt AC 56 ms 19968 KiB
01_random_01.txt AC 117 ms 41076 KiB
01_random_02.txt AC 56 ms 19568 KiB
01_random_03.txt AC 121 ms 43168 KiB
01_random_04.txt AC 35 ms 12876 KiB
01_random_05.txt AC 65 ms 23472 KiB
01_random_06.txt AC 45 ms 16104 KiB
01_random_07.txt AC 40 ms 14648 KiB
01_random_08.txt AC 63 ms 22496 KiB
01_random_09.txt AC 130 ms 44936 KiB
02_corner_00.txt AC 2 ms 2872 KiB
02_corner_01.txt AC 136 ms 46488 KiB
02_corner_02.txt AC 133 ms 46432 KiB
02_corner_03.txt AC 133 ms 46480 KiB
02_corner_04.txt AC 132 ms 46264 KiB