QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#66043 | #5103. Fair Division | dani_tro# | WA | 0ms | 3344kb | C++14 | 1.3kb | 2022-12-06 01:45:01 | 2022-12-06 01:45:04 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
long long n, m, p, q;
double res = 0.0, f, st;
double pow1(double q, int st)
{
if(st == 0)return 1.0;
if(st == 1)return q;
double ans = pow1(q, st / 2) * pow(q, st / 2);
if(st % 2 == 0)ans *= q;
return ans;
}
bool tr(long long p, long long q)
{
long long p1 = 1, q1 = 1;
long long res = 0;
for(int i = 0; i < n - 1; i++)
{
p1 *= p;
if(p1 < p)return false;
if(p1 > m || q1 > m)return false;
}
for(int i = 0; i < n; i++)
{
res += p1 * q1;
if(p1 > m || q1 > m || res > m)return false;
p1 /= p;
q1 *= q;
}
//cout << res << endl;
if(m % res != 0)return false;
return true;
}
int main()
{
/*int n = 6;
q = 2 * (1.0 / 3);
int m = 91000;
cout << m * ( 2 / (pow(3, n) - (pow(3 - 2, n)))) << endl;
st = 1.0;
for(int i = 0; i < n - 1; i++)st *= (1 - q);
for(int i = 1; i <= 10000; i++)
{
res += 91000 * q * (st);
for(int j = 0; j < n; j++)st *= (1 - q);
}
cout << res << endl;
*/
cin >> n >> m;
if(m < n)
{
cout << "impossible\n";
return 0;
}
for(int q = 1; q < 10000; q++)
{
for(int p = 1; p < q; p++)
{
if(tr(p, q) == true)
{
cout << p << " " << q << endl;
return 0;
}
}
}
cout << "impossible\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3344kb
input:
13 382475111752106101
output:
11 28
result:
wrong answer 1st lines differ - expected: '17 28', found: '11 28'