QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#106351#5103. Fair DivisionballanceWA 2ms3636kbC++141.5kb2023-05-17 15:06:222023-05-17 15:06:23

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:06:23]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3636kb
  • [2023-05-17 15:06:22]
  • 提交

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;
}
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n, m; cin >> n >> m;
	for (int q = 2;; q++)
	{
		ll a = pow(q, n);
		if (m < a / (q - 1) - 1)
			cout << "impossible", exit(0);
		for (int r = q - 1; r > 0; r--)
		{
			ll b = pow(r, n);
			if (m % ((a - b) / (q - r)) == 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: 3508kb

input:

13 382475111752106101

output:

17 28

result:

ok single line: '17 28'

Test #2:

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

input:

59 576460752303423487

output:

1 2

result:

ok single line: '1 2'

Test #3:

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

input:

15 227368755046033249

output:

13 14

result:

ok single line: '13 14'

Test #4:

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

input:

27 72027091647987988

output:

1 4

result:

ok single line: '1 4'

Test #5:

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

input:

12 817283057828223168

output:

10 17

result:

ok single line: '10 17'

Test #6:

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

input:

40 279103330129289325

output:

1 2

result:

ok single line: '1 2'

Test #7:

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

input:

9 200754090585004509

output:

27 31

result:

ok single line: '27 31'

Test #8:

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

input:

13 145272043713167318

output:

impossible

result:

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