QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#379913#5103. Fair DivisionUFRJ#WA 2ms3576kbC++20780b2024-04-06 19:52:272024-04-06 19:52:28

Judging History

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

  • [2024-04-06 19:52:28]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3576kb
  • [2024-04-06 19:52:27]
  • 提交

answer

#include "bits/stdc++.h"
using namespace std;
using lint = int64_t;
const int ms = 1e5;

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    lint N, M;
    cin>>N>>M;
    __int128_t m = M;
    for(int q=2;q<ms;q++){
        for(int p=1;p<q;p++){
            __int128_t l = 1, r = 1;
            bool ok = true;
            for(int i=0;i<N;i++){
                l *= q;
                r *= (q - p);
                if(l - r > 5 * m * p){
                    ok = false;
                    break; 
                }
            }
            if(!ok) break;
            if( (m * p) % (l - r) == 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: 2ms
memory: 3576kb

input:

13 382475111752106101

output:

impossible

result:

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