QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#745406#5103. Fair DivisionsjcxWA 227ms3796kbC++14989b2024-11-14 09:45:462024-11-14 09:45:48

Judging History

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

  • [2024-11-14 09:45:48]
  • 评测
  • 测评结果:WA
  • 用时:227ms
  • 内存:3796kb
  • [2024-11-14 09:45:46]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<random>
#include<ctime>
using namespace std;
#define re int
#define ll long long
inline ll read(){
    ll x=0,ff=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')ff=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^'0');c=getchar();}
    return x*ff;
}
ll n,m;
inline __int128 ksm(__int128 x,ll y){
	__int128 s=1;
	while(y){
		if(y&1)s*=x;
		x*=x;y>>=1;
	}
	return s;
}
int main(){
	n=read();m=read();bool ok=0;
	for(re i=2;i<=4000;i++){
		if(n>62)break;
		//if(ksm(i,n)-ksm(i-1,n)>m)break;
		for(re j=i-1;j>1;j--){
			__int128 tuu=ksm(i,n)-ksm(i-j,n);
			// if(i==28&&j==17){
			// 	long long uut=tuu;cout<<uut<<endl;
			// }
			if(tuu<=0)continue;
			if(tuu%j==0)tuu/=j;
			if(m%tuu==0){
				ok=1;
				cout<<j<<" "<<i<<endl;return 0;
			}
		}
	}
	if(!ok)puts("impossible");
    return 0;
}

详细

Test #1:

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

input:

13 382475111752106101

output:

17 28

result:

ok single line: '17 28'

Test #2:

score: -100
Wrong Answer
time: 227ms
memory: 3768kb

input:

59 576460752303423487

output:

impossible

result:

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