QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#408701#5103. Fair DivisionberarchegasWA 0ms3764kbC++141.3kb2024-05-10 21:35:162024-05-10 21:35:18

Judging History

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

  • [2024-05-10 21:35:18]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3764kb
  • [2024-05-10 21:35:16]
  • 提交

answer

#include <bits/stdc++.h>
#define O_O
using namespace std;
using ll = long long;
#define int ll
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ff first
#define ss second
mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());
    
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 5;
const int INF = 1e9;

int n, m;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>> n>> m;

    vector<__int128> vec{1};
    for(int a=2;; a++)
    {
        bool passou = false;
        __int128 pa = 1;
        for(int i=0; i<n; i++)
        {
            pa *= a;
            if(pa - vec.back() > m)
            {
                passou = true;
                break;
            } 
        }
        if(passou)
            break;
        // cout<< a<< " "<< (long long)pa<< endl;
        vec.push_back(pa);
    }
    for(int i=0; i<vec.size(); i++)
    {
        for(int j=i-1; j>=0; j--)
        {
            __int128 qn = vec[i], qmpn = vec[j];
            int q = i+1;
            int qmp = j+1;
            int p = q - qmp;
            if(((__int128)m * p) % (qn - qmpn) == 0)
            {
                cout<< p<< " "<< q<< "\n";
                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: 3764kb

input:

13 382475111752106101

output:

impossible

result:

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