QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#106349#5103. Fair DivisionballanceWA 2ms3512kbC++141.5kb2023-05-17 15:04:282023-05-17 15:04:29

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:04:29]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3512kb
  • [2023-05-17 15:04:28]
  • 提交

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))
			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);
		}
	}
}

詳細信息

Test #1:

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

input:

13 382475111752106101

output:

17 28

result:

ok single line: '17 28'

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3436kb

input:

59 576460752303423487

output:

impossible

result:

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