QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#469685#8008. Fortune WheelSunsetLakeWA 0ms3592kbC++141.0kb2024-07-09 21:56:472024-07-09 21:56:47

Judging History

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

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

answer

#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
const int N = 1e5 + 5,M = 505,inf = 1e9 + 7;
int n,m,x,k[N];
int dis[N],id[N];
queue<int>q;
bool cmp(int i,int j){
	return dis[i] < dis[j];
}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin >> n >> x >> m;
	for(int i = 1;i <= m;++ i) cin >> k[i];
	for(int i = 0;i <= n;++ i) dis[i] = inf;
	dis[0] = 0;
	q.push(0);
	while(!q.empty()){
		int u = q.front();
		q.pop();
		for(int i = 1;i <= m;++ i){
			int v = (u + k[i]) % n;
			if(dis[v] > dis[u] + 1){
				dis[v] = dis[u] + 1;
				q.push(v);
			}
		}
	}
	ll ap = inf,aq = 1;
	if(dis[x] < inf) ap = dis[x];
	for(int i = 0;i < n;++ i) id[i] = i;
	sort(id,id + n,cmp);
	ll sum = 0,sz = 0;
	for(int i = 0;i < n;++ i){
		if(dis[id[i]] == inf) break;
		sum += dis[id[i]];sz ++;
		ll nx = n + sum,ny = sz;
		if(nx * aq < ny * ap)
			aq = nx,ap = ny;
	}
	ll g = __gcd(aq,ap);
	aq /= g;ap /= g;
	cout << ap << " " << aq;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6 3 2
2 4

output:

1 6

result:

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