QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#536599#5103. Fair DivisionRngBased#WA 0ms3732kbC++201.1kb2024-08-29 14:53:532024-08-29 14:53:53

Judging History

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

  • [2024-08-29 14:53:53]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3732kb
  • [2024-08-29 14:53:53]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<double, double>
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;

const ll big = 2e18;
ll safe_mul(ll a, ll b)
{
    if (big / b < a)
        return big;
    else 
        return a * b;
}

ll n, m, pw[5005][35];

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    
    cin >> n >> m;

    if (n >= 30)
    {
        cout << "impossible\n";
        return 0;
    }

    for (ll q = 1; q <= 4000; q++)
    {    
        pw[q][0] = 1;
        for (int i = 1; i < n; i++)
            pw[q][i] = safe_mul(pw[q][i - 1], q);

        for (ll rp = 1; rp < q; rp++)
        {
            ll p = q - rp;
            ll sum = 0;
            for (int i = 0; i < n; i++)
                sum = min(big, sum + safe_mul(pw[p][i], pw[q][n - i - 1]));
            if (m % sum == 0)
            {
                cout << rp << ' ' << q << '\n';
                return 0;
            }
        }
    }
        cout << "impossible\n";

}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3732kb

input:

13 382475111752106101

output:

17 28

result:

ok single line: '17 28'

Test #2:

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

input:

59 576460752303423487

output:

impossible

result:

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