QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#106356#5103. Fair DivisionballanceWA 2ms3664kbC++141.8kb2023-05-17 15:15:442023-05-17 15:15:46

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-17 15:15:46]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3664kb
  • [2023-05-17 15:15:44]
  • 提交

answer

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <sstream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<set>
#include<stack>
#include<map>
#include<array>
#include<queue>
#include<cstring>
#include<stdio.h>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<unordered_map>
#include<random>
typedef unsigned long long ll;
typedef long double ld;
#define pii pair<int, int> 
#define pb push_back
#define fi first
#define se second
using namespace std;
const int N = 2010;
const ll x = 998244353, y = 1000000007;
void TLE() { while (1); }
void MLE() { while (1)int* a = new int[500000] {}; }
void RA() { set<int>a; cout << *a.end(); }

set<int>cnt;
vector<int>b[N], ask[N];;
map<pii, int>lca;
int col[N], fa[N];
pii makepair(int x, int y)
{
	return x < y ? make_pair(x, y) : make_pair(y, x);
}
int get(int x)
{
	if (x == fa[x])
		return x;
	return fa[x] = get(fa[x]);
}
void tarjan(int k, int f)
{
	col[k] = 1;
	for (int i : b[k])
		if (i != f)
		{
			tarjan(i, k);
			fa[i] = k;
		}
	for (int i : ask[k])
		if (col[i] == 2)
			lca[makepair(i, k)] = get(i);
	col[k] = 2;
}
ld power(ll a, ll b) {
	if (b == 0)return 1;
	if (b % 2 == 0)return power(a * a, b / 2);
	return a * power(a * a, b / 2);
}
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//cout << (11 * 145272043713167318ull) % ll(power(19, 13) - power(8, 13));
	/*ll a = 19;
	for (int i = 1; i <= 13; i++)
	{
		cout << a << '\n';
		a *= 19;
	}exit(0);*/
	ll n, m; cin >> n >> m;
	for (int q = 2;; q++)
	{
		ld a = pow(q, n);
		if (m < a / (q - 1) - 1)
			cout << "impossible", exit(0);
		for (int r = q - 1; r > 0; r--)
		{
			ld b = pow(r, n);
			ld c = (a - b) / (q - r);
			if (m % ll(c) == 0)
				cout << q - r << ' ' << q, exit(0);
		}
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3576kb

input:

13 382475111752106101

output:

17 28

result:

ok single line: '17 28'

Test #2:

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

input:

59 576460752303423487

output:

1 2

result:

ok single line: '1 2'

Test #3:

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

input:

15 227368755046033249

output:

13 14

result:

ok single line: '13 14'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3664kb

input:

27 72027091647987988

output:

1 4

result:

ok single line: '1 4'

Test #5:

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

input:

12 817283057828223168

output:

10 17

result:

ok single line: '10 17'

Test #6:

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

input:

40 279103330129289325

output:

1 2

result:

ok single line: '1 2'

Test #7:

score: 0
Accepted
time: 1ms
memory: 3440kb

input:

9 200754090585004509

output:

27 31

result:

ok single line: '27 31'

Test #8:

score: -100
Wrong Answer
time: 0ms
memory: 3408kb

input:

13 145272043713167318

output:

impossible

result:

wrong answer 1st lines differ - expected: '11 19', found: 'impossible'