QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#391351#5103. Fair DivisionsurenjamtsWA 0ms3648kbC++141.1kb2024-04-16 15:46:082024-04-16 15:46:08

Judging History

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

  • [2024-04-16 15:46:08]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3648kb
  • [2024-04-16 15:46:08]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define ll long long 

ll n, m;
ll zereg[1045][64];
bool check(int a, int b, int c){
	if(a>c) return false;
	double x, y, z, p;
	x=a;
	y=b;
	z=c;
	p=c/b;
	if(x>p) return false;
	else return true;
}
int of(int q){
	ll p=1;
	zereg[q][0]=1;
	for(int i=1;i<n;i++){
	     if(check(p, q, m)){
	     	p*=q;
	     	zereg[q][i]=p;
		 } else return 0;
	}
	return p;	
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(NULL);
cin>>n>>m;
for(int i=0;i<64;i++){
	zereg[1][i]=1;
}

	for(int q=2;q<=1e4+1;q++){
		ll z=of(q);
		if(z!=0) {
			for(int p=1;p<q;p++){
			
				if(m%(q-p)==0){
			
					ll rem=m/(q-p);
					ll sum=0;
					bool flag=true;
					for(int i=0;i<n;i++){
						sum+=zereg[p][i]*zereg[q][n-i-1];
					//	cout<<zereg[p][i]<<" "<<zereg[q][n-i-1]<<endl;
						if(sum>rem) {
							flag=false;
							break;
							
						}
					}
				
					if(flag && rem%sum==0){
						cout<<q-p<<" "<<q<<endl;
						return 0;
					}
						
					
					
					
				}
			}
		} else break;
	}
	
	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: 3648kb

input:

13 382475111752106101

output:

impossible

result:

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