QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#65060#5103. Fair DivisionlittlefermatWA 3ms3516kbC++14810b2022-11-26 22:03:532022-11-26 22:03:55

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-11-26 22:03:55]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3516kb
  • [2022-11-26 22:03:53]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fast ios::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
using namespace std;
const ll INF = 1e18;
ld power(ll a, ll b){
    if(b==0)return 1;
    if(b%2==0)return power(a*a, b/2);
    return a*power(a*a, b/2);
}

ll n,m;
ld c;
int main(){
    fast;
    cin>>n>>m;
    if(n>60)cout<<"impossible";
    else{
        ll maxi = floor(pow(10, 18.0/(n-1)));
        for(int i=2;i<maxi; i++){
            for(int j=i-1; j>0; j--){
                c = power(i,n)-power(j,n);
                c/=(i-j);
                if(c<=INF && m%((ll)c)==0){
                    cout<<i-j<<" "<<i;
                    return 0;
                }
            }
        }
        cout<<"impossible";
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 3ms
memory: 3468kb

input:

13 382475111752106101

output:

17 28

result:

ok single line: '17 28'

Test #2:

score: -100
Wrong Answer
time: 3ms
memory: 3516kb

input:

59 576460752303423487

output:

impossible

result:

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