QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#768312#5103. Fair DivisionuglassesWA 0ms3584kbC++14638b2024-11-21 09:05:092024-11-21 09:05:10

Judging History

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

  • [2024-11-21 09:05:10]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3584kb
  • [2024-11-21 09:05:09]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m;
int p,q,r;
int ksm(int x,int y)
{
	int res=1;
	int z=x;
	while(y)
	{
		if(y&1) res*=z;
		z*=z;
		y>>=1;
	}
	return res;
}
int gcd(int x,int y)
{
	if(y==0) return x;
	return gcd(y,x%y);
}
signed main()
{
//	cout<<ksm(3,4);
	cin>>n>>m;
	for(int q=2;ksm(q,n)<=m;q++)
	{
		for(int p=1;p<q&&gcd(q,p)==1;p++)
		{
			__int128 sum=0;
			for(int i=0;i<n;i++)
			{
				sum+=(__int128(ksm(q,i)*ksm(p,n-i-1)));
			}
			if(m%sum==0) 
			{
				cout<<(q-p)<<" "<<q<<endl;
				return 0;
			}
		}
	}
	cout<<"impossible\n";
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3584kb

input:

13 382475111752106101

output:

impossible

result:

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