QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#469504#8008. Fortune WheelczcWA 172ms4696kbC++23951b2024-07-09 19:48:382024-07-09 19:48:38

Judging History

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

  • [2024-07-30 15:38:33]
  • hack成功,自动添加数据
  • (/hack/759)
  • [2024-07-10 08:02:33]
  • hack成功,自动添加数据
  • (/hack/730)
  • [2024-07-09 19:48:38]
  • 评测
  • 测评结果:WA
  • 用时:172ms
  • 内存:4696kb
  • [2024-07-09 19:48:38]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int dis[maxn],id[maxn];
int n,x,m;
#define ll long long
struct node{
	ll p,q;
};
inline bool operator < (node x,node y){
	return x.p*y.q<y.p*x.q;
}
inline node Min(node x,node y){
	return x<y?x:y;
}
const ll INF=1e18;
int main(){
	scanf("%d%d%d",&n,&x,&m);
	dis[0]=0;
	for(int i=1;i<n;i++) dis[i]=1e7,id[i]=i;
	for(int i=1,k;i<=m;i++){
		scanf("%d",&k);
		for(int j=0;j<__gcd(k,n);j++){
			for(int ct=0,c=j;ct<3;ct+=(c==j)){
				int p=(c+k)%n;
				dis[c]=min(dis[c],dis[p]+1);
				c=p;
			}
		}
	}
	sort(id,id+n,[](int x,int y){return dis[x]<dis[y];});
	node ans=(node){INF,1ll};
	ll sum=0;
	for(int i=0;i<n;i++){
		if(id[i]==x){
			ans=min(ans,(node){dis[id[i]],1});
		}
		else{
			sum+=dis[id[i]];
			ans=min(ans,(node){sum+(ll)n,i+1});
		}
	}
	ll g=__gcd(ans.p,ans.q);
	ans.p/=g,ans.q/=g;
	printf("%lld %lld",ans.p,ans.q);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6 3 2
2 4

output:

8 3

result:

ok 2 number(s): "8 3"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3904kb

input:

5 4 1
1

output:

1 1

result:

ok 2 number(s): "1 1"

Test #3:

score: 0
Accepted
time: 172ms
memory: 4696kb

input:

99999 65238 100
64714 45675 36156 13116 93455 22785 10977 60219 14981 25839 83709 80404 41400 12469 31530 65521 35436 20326 96792 50699 27522 98233 26187 12509 90992 72693 83919 74145 80892 68422 38333 33497 89154 88403 77492 4570 3908 59194 3482 89871 96330 45114 5555 73987 95832 476 949 74649 2084...

output:

3 1

result:

ok 2 number(s): "3 1"

Test #4:

score: -100
Wrong Answer
time: 2ms
memory: 3984kb

input:

10000 23 7
9594 8998 9330 6851 1662 6719 583

output:

22079 2355

result:

wrong answer 1st numbers differ - expected: '42726', found: '22079'