Submission #3789954


Source Code Expand

#if 0
cat <<EOF >mistaken-paste
#endif
// thanks for @rsk0315_h4x

#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <time.h>

#define BIG 2000000007
#define VERYBIG 2000000000000007LL

#define MOD 1000000007
#define FOD  998244353
typedef uint64_t ull;
typedef  int64_t sll;

#define N_MAX 1000000

#ifdef __cplusplus
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <functional>
#include <array>

using std::queue;
using std::priority_queue;
using std::stack;
using std::tuple;
using std::set;
using std::map;
using std::vector;
using std::greater;
using std::pair;
using std::string;
using std::get;

template <typename T, typename U>
pair<T, U> operator+(pair<T, U> l, pair<T, U> r) {
	return pair<T, U>(l.first + r.first, l.second + r.second);
}

#endif

typedef struct {
	int32_t a;
	int32_t b;
} hw;

typedef struct {
	sll a;
	sll b;
} hwll;

typedef struct {
	sll a;
	sll b;
	sll c;
} hwllc;

typedef struct {
	hwll a;
	hwll b;
} linell;

ull n, m;
ull h, w;
ull k;
ull q;
sll va, vb, vc, vd, ve, vf;
ull ua, ub, uc, ud, ue, uf;
long double vra, vrb, vrc;
double vda, vdb, vdc;
char ch, dh;

ull umin (ull x, ull y) {
	return (x < y) ? x : y;
}

ull umax (ull x, ull y) {
	return (x > y) ? x : y;
}

sll smin (sll x, sll y) {
	return (x < y) ? x : y;
}

sll smax (sll x, sll y) {
	return (x > y) ? x : y;
}

ull gcd (ull x, ull y) {
	if (x < y) {
		return gcd(y, x);
	} else if (y == 0) {
		return x;
	} else {
		return gcd(y, x % y);
	}
}

ull bitpow (ull a, ull x, ull modulo) {
	ull result = 1;
	while (x) {
		if (x & 1) {
			result *= a;
			result %= modulo;
		}
		x /= 2;
		a = (a * a) % modulo;
	}
	return result;
}

ull divide (ull a, ull b, ull modulo) {
	return (a * bitpow(b, modulo - 2, modulo)) % modulo;
}

ull udiff (ull a, ull b) {
	if (a >= b) {
		return a - b;
	} else {
		return b - a;
	}
}

sll sdiff (sll a, sll b) {
	if (a >= b) {
		return a - b;
	} else {
		return b - a;
	}
}

int bitcount (ull n) {
	int result = 0;
	while (n) {
		if (n & 1) result++;
		n /= 2;
	}
	return result;
}

#define BEGCMP(NAME) int32_t NAME (const void *left, const void *right)
#define DEFLR(TYPE) TYPE l=*(TYPE*)left,r=*(TYPE*)right
#define CMPRET(L, R) if((L)<(R))return-1;if((L)>(R))return+1

// int32_t pullcomp (const void *left, const void *right) {
// 	ull l = *(ull*)left;
// 	ull r = *(ull*)right;
// 	if (l < r) {
// 		return -1;
// 	}
// 	if (l > r) {
// 		return +1;
// 	}
// 	return 0;
// }
BEGCMP(pullcomp){
	DEFLR(ull);
	CMPRET(l, r);
	return 0;
}
BEGCMP(prevcomp){
	DEFLR(ull);
	CMPRET(r, l);
	return 0;
}
BEGCMP(psllcomp){
	DEFLR(sll);
	CMPRET(l, r);
	return 0;
}
BEGCMP(pcharcomp){
	DEFLR(char);
	CMPRET(l, r);
	return 0;
}
BEGCMP(pdoublecomp){
	DEFLR(double);
	CMPRET(l, r);
	return 0;
}

int32_t pstrcomp (const void *left, const void *right) {
	char* l = *(char**)left;
	char* r = *(char**)right;

	return strcmp(l, r);
}

BEGCMP(phwllABcomp){
	DEFLR(hwll);
	CMPRET(l.a, r.a);
	CMPRET(l.b, r.b);
	return 0;
}
BEGCMP(phwllREVcomp){
	DEFLR(hwll);
	CMPRET(l.b, r.b);
	CMPRET(l.a, r.a);
	return 0;
}
BEGCMP(ptriplecomp){
	DEFLR(hwllc);
	CMPRET(l.a, r.a);
	CMPRET(l.b, r.b);
	CMPRET(l.c, r.c);
	return 0;
}
BEGCMP(ptripleREVcomp){
	DEFLR(hwllc);
	CMPRET(l.b, r.b);
	CMPRET(l.a, r.a);
	CMPRET(l.c, r.c);
	return 0;
}

int32_t pquadcomp (const void *left, const void *right) {
	linell l = *(linell*)left;
	linell r = *(linell*)right;

	sll ac = phwllABcomp(&(l.a), &(r.a));
	if (ac) return ac;
	sll bc = phwllABcomp(&(l.b), &(r.b));
	if (bc) return bc;

	return 0;
}

bool isinrange (sll left, sll x, sll right) {
	return (left <= x && x <= right);
}

bool isinrange_soft (sll left, sll x, sll right) {
	return (left <= x && x <= right) || (left >= x && x >= right);
}

// sll a[N_MAX + 5];
ull a[N_MAX + 5];
// sll a[3001][3001];
// sll b[N_MAX + 5];
ull b[N_MAX + 5];
// sll b[3001][3001];
ull c[N_MAX + 5];
ull d[N_MAX + 5];
sll e[N_MAX];
char s[N_MAX + 1];
// char s[3010][3010];
char t[N_MAX + 1];
// char t[3010][3010];
// char u[N_MAX + 1];
hwll xy[N_MAX + 5];
hwllc tup[N_MAX + 5];
sll table[3000][3000];
// here we go

ull ncr[32][32];
ull dp[32][32][32];

ull solve () {
	sll i, j, ki, li;
	// ull result = 0;
	sll result = 0;
	double dresult = 0;
	// ull maybe = 0;
	sll maybe = 0;
	// ull sum = 0;
	sll sum = 0;
	sll item;
	ull *dpcell;

	ull x, y;
	scanf("%llu/%llu", &x, &y);
	// (n+1)/2 - m/n
	// (n-1)/2 <= X/Y < (n+1)/2
	// n/2 <= X/Y + 1/2 < n/2+1
	// n <= 2X/Y + 1 < n+2
	// floor(2X/Y) = n-1, n

	ull g = gcd(x, y);
	x /= g;
	y /= g;

	ull a = (x / y) * 2;
	while ((a * y - 1) / 2 < x) a++;
	if (a) a--;

	// n(n+1)/2 - nX/Y

	n = a;
	if (n % y == 0) {
		m = n * (n + 1) / 2 - (n / y) * x;
		if (1 <= m && m <= n) {
			sum++;

			printf("%llu %llu\n", n, m);
		}
	}
	n = a + 1;
	if (n % y == 0) {
		m = n * (n + 1) / 2 - (n / y) * x;
		if (1 <= m && m <= n) {
			sum++;

			printf("%llu %llu\n", n, m);
		}
	}

	if (!sum) {
		puts("Impossible");
	}

	// printf("%lld\n", result);
	// printf("%.15lf\n", dresult);
	// puts(s);

	return 0;

	success:
	// puts("YES");
	puts("Yes");
	// printf("%llu\n", result);
	// puts("0");
	// puts("Yay!");
	return 0;

	fail:
	// puts("NO");
	// puts("No");
	// puts("0");
	puts("-1");
	// puts("-1 -1 -1");
	// puts("Impossible");
	return 1;
}

int32_t main (void) {
	int32_t i, j;
	int32_t x, y;



	// scanf("%llu%llu", &h, &w);
	// scanf("%llu", &n, &m);
	// scanf("%llu", &k, &n, &m);
	// scanf("%llu%llu", &h, &w);
	// scanf("%llu", &q);
	// scanf("%s", s);
	// scanf("%lld%lld", &va, &vb, &vc, &vd);
	// scanf("%llu%llu%llu", &ua, &ub, &uc, &ud);
	// scanf("%s", t);
	// scanf("%lld", &m);
	// for (i = 0; i < n; i++) {
	// 	// scanf("%lld%lld", &xy[i].a, &xy[i].b);
	// 	// scanf("%lld%lld%lld", &tup[i].a, &tup[i].b, &tup[i].c);
	// 	scanf("%llu", &a[i]);
	// 	// scanf("%llu", &b[i]);
	// 	// scanf("%lld", &c[i]);
	// 	// scanf("%lld", &d[i]);
	// 	// a[i]--;
	// 	// b[i]--;
	// 	// c[i]--;
	// 	// d[i]--;
	// 	// tup[i].a--;
	// 	// tup[i].b--;
	// }
	// scanf("%llu", &m, &k);
	// scanf("%llu", &q);
	// scanf("%s", s);
	// for (i = 0; i < n; i++) {
	// 	scanf("%llu", &c[i]);
	// 	// c[i]--;
	// }
	// scanf("%llu", &q);



	// for (i = 0; i < h; i++) {
	// 	for (j = 0; j < w; j++) {
	// 		scanf("%lld", &table[i][j]);
	// 		// table[i][j]--;
	// 	}
	// }
	// for (i = 0; i < h; i++) {
	// 	scanf("%s", s[i]);
	// }
	// scanf("%llu", &q);

	solve();

	return 0;
}

Submission Info

Submission Time
Task C - 平均値太郎の憂鬱 ( The melancholy of Taro Heikinchi )
User sheyasutaka
Language C (GCC 5.4.1)
Score 100
Code Size 7012 Byte
Status AC
Exec Time 2 ms
Memory 4224 KB

Compile Error

./Main.c: In function ‘solve’:
./Main.c:286:8: warning: format ‘%llu’ expects argument of type ‘long long unsigned int *’, but argument 2 has type ‘ull * {aka long unsigned int *}’ [-Wformat=]
  scanf("%llu/%llu", &x, &y);
        ^
./Main.c:286:8: warning: format ‘%llu’ expects argument of type ‘long long unsigned int *’, but argument 3 has type ‘ull * {aka long unsigned int *}’ [-Wformat=]
./Main.c:309:11: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘ull {aka long unsigned int}’ [-Wformat=]
    printf("%llu %llu\n", n, m);
           ^
./Main.c:309:11: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘ull {aka long unsigned int}’ [-Wformat=]
./Main.c:318:11: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘ull {aka long unsigned int}’ [-Wformat=]
    printf("%llu %llu\n", n, m);
           ^
./Main.c:318:11: warning: format ‘%llu’ expects argument of typ...

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 2176 KB
00_max.txt AC 1 ms 4224 KB
00_min.txt AC 1 ms 4224 KB
00_min2.txt AC 1 ms 4224 KB
00_sample_01.txt AC 1 ms 4224 KB
00_sample_02.txt AC 1 ms 4224 KB
00_sample_03.txt AC 1 ms 4224 KB
00_sample_04.txt AC 1 ms 4224 KB
01_rnd_00.txt AC 1 ms 2176 KB
01_rnd_01.txt AC 1 ms 2176 KB
01_rnd_02.txt AC 1 ms 2176 KB
01_rnd_03.txt AC 1 ms 2176 KB
01_rnd_04.txt AC 1 ms 2176 KB
01_rnd_05.txt AC 1 ms 2176 KB
01_rnd_06.txt AC 1 ms 2176 KB
01_rnd_07.txt AC 1 ms 2176 KB
01_rnd_08.txt AC 1 ms 2176 KB
01_rnd_09.txt AC 1 ms 4224 KB
01_rnd_10.txt AC 1 ms 2176 KB
01_rnd_11.txt AC 1 ms 2176 KB
01_rnd_12.txt AC 1 ms 2176 KB
01_rnd_13.txt AC 1 ms 2176 KB
01_rnd_14.txt AC 1 ms 2176 KB
01_rnd_15.txt AC 1 ms 2176 KB
01_rnd_16.txt AC 1 ms 4224 KB
01_rnd_17.txt AC 1 ms 2176 KB
01_rnd_18.txt AC 1 ms 4224 KB
01_rnd_19.txt AC 1 ms 4224 KB
02_rnd2_00.txt AC 1 ms 2176 KB
02_rnd2_01.txt AC 1 ms 2176 KB
02_rnd2_02.txt AC 1 ms 2176 KB
02_rnd2_03.txt AC 1 ms 2176 KB
02_rnd2_04.txt AC 1 ms 2176 KB
02_rnd2_05.txt AC 1 ms 2176 KB
02_rnd2_06.txt AC 1 ms 2176 KB
02_rnd2_07.txt AC 1 ms 2176 KB
02_rnd2_08.txt AC 1 ms 2176 KB
02_rnd2_09.txt AC 1 ms 2176 KB
02_rnd2_10.txt AC 1 ms 2176 KB
02_rnd2_11.txt AC 1 ms 2176 KB
02_rnd2_12.txt AC 1 ms 2176 KB
02_rnd2_13.txt AC 1 ms 2176 KB
02_rnd2_14.txt AC 2 ms 2176 KB
02_rnd2_15.txt AC 1 ms 2176 KB
02_rnd2_16.txt AC 1 ms 2176 KB
02_rnd2_17.txt AC 1 ms 2176 KB
02_rnd2_18.txt AC 1 ms 2176 KB
02_rnd2_19.txt AC 1 ms 2176 KB
03_smallrnd_00.txt AC 1 ms 2176 KB
03_smallrnd_01.txt AC 1 ms 2176 KB
03_smallrnd_02.txt AC 1 ms 4224 KB
03_smallrnd_03.txt AC 1 ms 2176 KB
03_smallrnd_04.txt AC 1 ms 4224 KB
03_smallrnd_05.txt AC 1 ms 4224 KB
03_smallrnd_06.txt AC 1 ms 4224 KB
03_smallrnd_07.txt AC 1 ms 2176 KB
03_smallrnd_08.txt AC 1 ms 4224 KB
03_smallrnd_09.txt AC 1 ms 4224 KB
04_primes_01.txt AC 1 ms 4224 KB
04_primes_02.txt AC 1 ms 4224 KB