Submission #3461469


Source Code Expand

#include<bits/stdc++.h>
#include<bits/extc++.h>

#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define go(x, i) for(register int i = head[x]; i; i = nxt[i])
#define For(i, a, b) for(register int i = (a), i##_end_ = (b); i <= i##_end_; ++ i)
#define FOR(i, a, b) for(register int i = (a), i##_end_ = (b); i >= i##_end_; -- i)
#define debug(x) cout << #x << " = " << x << endl
#define mem(a, b) memset(a, b, sizeof(a))
#define cpy(a, b) memcpy(a, b, sizeof(a))
#define inf (0x3f3f3f3f)
#define INF (1e18)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define y1 orzorz

typedef unsigned long long ull;
typedef unsigned int uint;
typedef long long ll;
typedef std::pair<ll, int> PLI;
typedef std::pair<int, int> PII;
typedef long double ldb;
typedef __int128 LL;
typedef double db;

namespace IO {
#define getc() ((S_ == T_) && (T_ = (S_ = Ch_) + fread(Ch_, 1, Buffsize, stdin), S_ == T_) ? 0 : *S_ ++)
#define putc(x) *nowps ++ = (x)

	const uint Buffsize = 1 << 15, Output = 1 << 23;
	static char Ch_[Buffsize], *S_ = Ch_, *T_ = Ch_;
	static char Out[Output], *nowps = Out;

	inline void flush() {fwrite(Out, 1, nowps - Out, stdout); nowps = Out;}
	template<class T>inline bool chkmax(T &_, T __) {return _ < __ ? _ = __, 1 : 0;}
	template<class T>inline bool chkmin(T &_, T __) {return _ > __ ? _ = __, 1 : 0;}

	template<class T>inline void read(T &_) {
		_ = 0; static char __; T ___ = 1;
		for(__ = getc(); !isdigit(__); __ = getc()) if(__ == '-') ___ = -1;
		for(; isdigit(__); __ = getc()) _ = (_ << 3) + (_ << 1) + (__ ^ 48);
		_ *= ___;
	}

	template<class T>inline void write(T _, char __ = '\n') {
		if(!_) putc('0');
		if(_ < 0) putc('-'), _ = -_;
		static uint sta[111], tp;
		for(tp = 0; _; _ /= 10) sta[++ tp] = _ % 10;
		for(; tp; putc(sta[tp --] ^ 48)); putc(__);
	}

	inline void procStatus() {
		std::ifstream t("/proc/self/status");
		std::cerr << std::string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
	}
}

using namespace std;
using namespace IO;

vector<pair<LL, LL> > ans;

LL x, y;

int main() {
#ifdef ylsakioi
	file("AT186");
#endif

	read(x), read(y);
	for(LL n = 2 * x / y - 1; n <= 2 * x / y + 2; ++ n) 
		if((n * n * y + (y - x * 2) * n) % (y * 2) == 0) {
			LL m = (n * n * y + (y - x * 2) * n) / (y * 2);
			if(n > 0 && m > 0 && m <= n) ans.pb(mp(n, (n * n * y + (y - x * 2) * n) / (y * 2)));
		}

	if(ans.empty()) puts("Impossible");
	else for(auto v : ans) write(v.x, ' '), write(v.y);
	
	// (n + 1) / 2 - m / n = x / y
	// n + 1 - 2m / n = 2x / y
	// n = 2x / y + 2m / n - 1
	// 2x / y - 1 <= n <= 2x / y + 2

	return flush(), 0;
}

Submission Info

Submission Time
Task C - 平均値太郎の憂鬱 ( The melancholy of Taro Heikinchi )
User luogu_bot2
Language C++14 (GCC 5.4.1)
Score 100
Code Size 2652 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 60
Set Name Test Cases
All 00_killer.txt, 00_max.txt, 00_min.txt, 00_min2.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, 01_rnd_00.txt, 01_rnd_01.txt, 01_rnd_02.txt, 01_rnd_03.txt, 01_rnd_04.txt, 01_rnd_05.txt, 01_rnd_06.txt, 01_rnd_07.txt, 01_rnd_08.txt, 01_rnd_09.txt, 01_rnd_10.txt, 01_rnd_11.txt, 01_rnd_12.txt, 01_rnd_13.txt, 01_rnd_14.txt, 01_rnd_15.txt, 01_rnd_16.txt, 01_rnd_17.txt, 01_rnd_18.txt, 01_rnd_19.txt, 02_rnd2_00.txt, 02_rnd2_01.txt, 02_rnd2_02.txt, 02_rnd2_03.txt, 02_rnd2_04.txt, 02_rnd2_05.txt, 02_rnd2_06.txt, 02_rnd2_07.txt, 02_rnd2_08.txt, 02_rnd2_09.txt, 02_rnd2_10.txt, 02_rnd2_11.txt, 02_rnd2_12.txt, 02_rnd2_13.txt, 02_rnd2_14.txt, 02_rnd2_15.txt, 02_rnd2_16.txt, 02_rnd2_17.txt, 02_rnd2_18.txt, 02_rnd2_19.txt, 03_smallrnd_00.txt, 03_smallrnd_01.txt, 03_smallrnd_02.txt, 03_smallrnd_03.txt, 03_smallrnd_04.txt, 03_smallrnd_05.txt, 03_smallrnd_06.txt, 03_smallrnd_07.txt, 03_smallrnd_08.txt, 03_smallrnd_09.txt, 04_primes_01.txt, 04_primes_02.txt
Case Name Status Exec Time Memory
00_killer.txt AC 1 ms 256 KB
00_max.txt AC 1 ms 256 KB
00_min.txt AC 1 ms 256 KB
00_min2.txt AC 1 ms 256 KB
00_sample_01.txt AC 1 ms 256 KB
00_sample_02.txt AC 1 ms 256 KB
00_sample_03.txt AC 1 ms 256 KB
00_sample_04.txt AC 1 ms 256 KB
01_rnd_00.txt AC 1 ms 256 KB
01_rnd_01.txt AC 1 ms 256 KB
01_rnd_02.txt AC 1 ms 256 KB
01_rnd_03.txt AC 1 ms 256 KB
01_rnd_04.txt AC 1 ms 256 KB
01_rnd_05.txt AC 1 ms 256 KB
01_rnd_06.txt AC 1 ms 256 KB
01_rnd_07.txt AC 1 ms 256 KB
01_rnd_08.txt AC 1 ms 256 KB
01_rnd_09.txt AC 1 ms 256 KB
01_rnd_10.txt AC 1 ms 256 KB
01_rnd_11.txt AC 1 ms 256 KB
01_rnd_12.txt AC 1 ms 256 KB
01_rnd_13.txt AC 1 ms 256 KB
01_rnd_14.txt AC 1 ms 256 KB
01_rnd_15.txt AC 1 ms 256 KB
01_rnd_16.txt AC 1 ms 256 KB
01_rnd_17.txt AC 1 ms 256 KB
01_rnd_18.txt AC 1 ms 256 KB
01_rnd_19.txt AC 1 ms 256 KB
02_rnd2_00.txt AC 1 ms 256 KB
02_rnd2_01.txt AC 1 ms 256 KB
02_rnd2_02.txt AC 1 ms 256 KB
02_rnd2_03.txt AC 1 ms 256 KB
02_rnd2_04.txt AC 1 ms 256 KB
02_rnd2_05.txt AC 1 ms 256 KB
02_rnd2_06.txt AC 1 ms 256 KB
02_rnd2_07.txt AC 1 ms 256 KB
02_rnd2_08.txt AC 1 ms 256 KB
02_rnd2_09.txt AC 1 ms 256 KB
02_rnd2_10.txt AC 1 ms 256 KB
02_rnd2_11.txt AC 1 ms 256 KB
02_rnd2_12.txt AC 1 ms 256 KB
02_rnd2_13.txt AC 1 ms 256 KB
02_rnd2_14.txt AC 1 ms 256 KB
02_rnd2_15.txt AC 1 ms 256 KB
02_rnd2_16.txt AC 1 ms 256 KB
02_rnd2_17.txt AC 1 ms 256 KB
02_rnd2_18.txt AC 1 ms 256 KB
02_rnd2_19.txt AC 1 ms 256 KB
03_smallrnd_00.txt AC 1 ms 256 KB
03_smallrnd_01.txt AC 1 ms 256 KB
03_smallrnd_02.txt AC 1 ms 256 KB
03_smallrnd_03.txt AC 1 ms 256 KB
03_smallrnd_04.txt AC 1 ms 256 KB
03_smallrnd_05.txt AC 1 ms 256 KB
03_smallrnd_06.txt AC 1 ms 256 KB
03_smallrnd_07.txt AC 1 ms 256 KB
03_smallrnd_08.txt AC 1 ms 256 KB
03_smallrnd_09.txt AC 1 ms 256 KB
04_primes_01.txt AC 1 ms 256 KB
04_primes_02.txt AC 1 ms 256 KB