QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#557713#5103. Fair DivisionevirirWA 0ms3856kbC++201.3kb2024-09-11 11:06:032024-09-11 11:06:04

Judging History

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

  • [2024-09-11 11:06:04]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3856kb
  • [2024-09-11 11:06:03]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define F first
#define S second
#define pb push_back
using ll = long long;
using ii = pair<ll, ll>;
using ld = long double;

const int MAXN = 1005;

using i128 = __int128;

int main()
{
    cin.tie(0)->sync_with_stdio(0);

    ll n, m; cin >> n >> m;

    fore(q,2,MAXN)
    {
        {
            bool ok = 1;
            ll qq = 1;
            // a * b > c <=> a > floor(c / b)
            forn(i, 0, n - 1)
            {
                if (qq > m / q)
                {
                    ok = 0;
                    break;
                }
                qq *= q;
            }
            if (qq > m / (q - 1)) ok = 0;
            if (!ok)
                continue;
        }

        fore(p,1,q-1)
        {
            i128 qq = 1;
            i128 pp = 1;
            fore(i,1,n)
            {
                qq *= q;
                pp *= p;
            }
            if (m % (qq - pp) == 0)
            {
                cout << p << ' ' << q << '\n';
                return 0;
            }
        }
    }
    cout << "impossible\n";

    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3856kb

input:

13 382475111752106101

output:

impossible

result:

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