QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#106349 | #5103. Fair Division | ballance | WA | 2ms | 3512kb | C++14 | 1.5kb | 2023-05-17 15:04:28 | 2023-05-17 15:04:29 |
Judging History
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'