Submission #68769089


Source Code Expand

#include <bits/stdc++.h>

#define rep(i, s, e) for(int i = s; i <= e; ++i)
#define fep(i, s, e) for(int i = s; i < e; ++i)
#define _rep(i, s, e) for(int i = s; i >= e; --i)
#define _fep(i, s, e) for(int i = s; i > e; --i)

#define int long long
#define pii pair<int, int>

namespace FastIO {
	template <typename _Tp> inline void read(_Tp &x) { int neg = 1; char ch; while(ch = getchar(), !isdigit(ch)) if(ch == '-') neg = -1; x = ch - '0'; while(ch = getchar(), isdigit(ch)) x = (x << 3) + (x << 1) + (ch ^ '0'); x *= neg; }
	template <typename _Tp, typename... _Args> inline void read(_Tp &x, _Args &...args) { read(x); read(args...); }
	template <typename _Tp> inline void read(_Tp* begin, _Tp* end) { int len = end - begin; for(int i = 0; i < len; ++i) read(*(begin + i)); }
	template <typename _Tp> inline void write(_Tp x) { if(x < 0) putchar('-'), x = -x; if(x > 9) write(x / 10); putchar(x % 10 + '0'); }
	template <typename _Tp, typename... _Args> inline void write(_Tp x, _Args ...args) { write(x); putchar(' '); write(args...); }
	template <typename _Tp> inline void write(_Tp* begin, _Tp* end) { int len = end - begin; for(int i = 0; i < len; ++i) write(*(begin + i)), putchar(' '); }
}

using namespace std;
using namespace FastIO;

constexpr int inf = numeric_limits<int>::max() / 2;
constexpr int ninf = numeric_limits<int>::min() / 2;
constexpr int mod = 998244353;
constexpr double eps = 0.000001;

int x, a, b, lst, u;
priority_queue<int, vector<int>, greater<int>> q;
vector<int> ans;

void solve() {
	read(x);
	rep(k, -30000000, 30000000) {
		a = k * k - x;
		b = 2 * k + 1;
		if(a % b == 0) q.push(a / b);
	}
	lst = ninf;
	while(!q.empty()) {
		u = q.top(); q.pop();
		if(u != lst) ans.push_back(u), lst = u;
	}
	printf("%lld\n", ans.size());
	for(auto i : ans) printf("%lld ", i);
	return;
}

signed main() {
	int T = 1;
	while(T--) solve();
	return 0;
}

Submission Info

Submission Time
Task G - sqrt(n²+n+X)
User Getaway_Car
Language C++ 20 (gcc 12.2)
Score 575
Code Size 1927 Byte
Status AC
Exec Time 175 ms
Memory 3872 KiB

Compile Error

Main.cpp: In function ‘void solve()’:
Main.cpp:44:20: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘std::vector<long long int>::size_type’ {aka ‘long unsigned int’} [-Wformat=]
   44 |         printf("%lld\n", ans.size());
      |                 ~~~^     ~~~~~~~~~~
      |                    |             |
      |                    long long int std::vector<long long int>::size_type {aka long unsigned int}
      |                 %ld

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 575 / 575
Status
AC × 3
AC × 63
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_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 01_handmade_06.txt, 01_handmade_07.txt, 01_handmade_08.txt, 01_handmade_09.txt, 01_handmade_10.txt, 01_handmade_11.txt, 01_handmade_12.txt, 01_handmade_13.txt, 01_handmade_14.txt, 01_handmade_15.txt, 01_handmade_16.txt, 01_handmade_17.txt, 01_handmade_18.txt, 01_handmade_19.txt, 01_handmade_20.txt, 01_handmade_21.txt, 01_handmade_22.txt, 01_handmade_23.txt, 01_handmade_24.txt, 01_handmade_25.txt, 01_handmade_26.txt, 01_handmade_27.txt, 01_handmade_28.txt, 01_handmade_29.txt, 01_handmade_30.txt, 01_handmade_31.txt, 01_handmade_32.txt, 01_handmade_33.txt, 01_handmade_34.txt, 01_handmade_35.txt, 01_handmade_36.txt, 01_handmade_37.txt, 01_handmade_38.txt, 01_handmade_39.txt, 01_handmade_40.txt, 01_handmade_41.txt, 01_handmade_42.txt, 01_handmade_43.txt, 01_handmade_44.txt, 01_handmade_45.txt, 01_handmade_46.txt, 01_handmade_47.txt, 01_handmade_48.txt, 01_handmade_49.txt, 02_radom_00.txt, 02_radom_01.txt, 02_radom_02.txt, 02_radom_03.txt, 02_radom_04.txt, 02_radom_05.txt, 02_radom_06.txt, 02_radom_07.txt, 02_radom_08.txt, 02_radom_09.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 174 ms 3580 KiB
00_sample_01.txt AC 174 ms 3752 KiB
00_sample_02.txt AC 173 ms 3692 KiB
01_handmade_00.txt AC 173 ms 3552 KiB
01_handmade_01.txt AC 173 ms 3612 KiB
01_handmade_02.txt AC 174 ms 3728 KiB
01_handmade_03.txt AC 174 ms 3616 KiB
01_handmade_04.txt AC 174 ms 3756 KiB
01_handmade_05.txt AC 174 ms 3588 KiB
01_handmade_06.txt AC 173 ms 3552 KiB
01_handmade_07.txt AC 173 ms 3636 KiB
01_handmade_08.txt AC 173 ms 3688 KiB
01_handmade_09.txt AC 173 ms 3724 KiB
01_handmade_10.txt AC 173 ms 3744 KiB
01_handmade_11.txt AC 173 ms 3756 KiB
01_handmade_12.txt AC 173 ms 3612 KiB
01_handmade_13.txt AC 174 ms 3680 KiB
01_handmade_14.txt AC 173 ms 3592 KiB
01_handmade_15.txt AC 174 ms 3764 KiB
01_handmade_16.txt AC 174 ms 3628 KiB
01_handmade_17.txt AC 173 ms 3516 KiB
01_handmade_18.txt AC 174 ms 3744 KiB
01_handmade_19.txt AC 173 ms 3616 KiB
01_handmade_20.txt AC 174 ms 3748 KiB
01_handmade_21.txt AC 173 ms 3724 KiB
01_handmade_22.txt AC 173 ms 3636 KiB
01_handmade_23.txt AC 174 ms 3552 KiB
01_handmade_24.txt AC 174 ms 3768 KiB
01_handmade_25.txt AC 174 ms 3760 KiB
01_handmade_26.txt AC 174 ms 3616 KiB
01_handmade_27.txt AC 173 ms 3616 KiB
01_handmade_28.txt AC 174 ms 3548 KiB
01_handmade_29.txt AC 174 ms 3748 KiB
01_handmade_30.txt AC 174 ms 3748 KiB
01_handmade_31.txt AC 174 ms 3764 KiB
01_handmade_32.txt AC 174 ms 3620 KiB
01_handmade_33.txt AC 173 ms 3576 KiB
01_handmade_34.txt AC 173 ms 3744 KiB
01_handmade_35.txt AC 173 ms 3684 KiB
01_handmade_36.txt AC 173 ms 3528 KiB
01_handmade_37.txt AC 173 ms 3676 KiB
01_handmade_38.txt AC 173 ms 3524 KiB
01_handmade_39.txt AC 174 ms 3584 KiB
01_handmade_40.txt AC 173 ms 3580 KiB
01_handmade_41.txt AC 174 ms 3760 KiB
01_handmade_42.txt AC 174 ms 3616 KiB
01_handmade_43.txt AC 173 ms 3576 KiB
01_handmade_44.txt AC 173 ms 3732 KiB
01_handmade_45.txt AC 174 ms 3744 KiB
01_handmade_46.txt AC 173 ms 3616 KiB
01_handmade_47.txt AC 173 ms 3760 KiB
01_handmade_48.txt AC 174 ms 3616 KiB
01_handmade_49.txt AC 175 ms 3872 KiB
02_radom_00.txt AC 173 ms 3584 KiB
02_radom_01.txt AC 174 ms 3616 KiB
02_radom_02.txt AC 173 ms 3552 KiB
02_radom_03.txt AC 173 ms 3612 KiB
02_radom_04.txt AC 174 ms 3524 KiB
02_radom_05.txt AC 174 ms 3620 KiB
02_radom_06.txt AC 174 ms 3576 KiB
02_radom_07.txt AC 174 ms 3752 KiB
02_radom_08.txt AC 173 ms 3580 KiB
02_radom_09.txt AC 174 ms 3580 KiB