QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#470871#8008. Fortune WheelRose_LuWA 1ms7660kbC++14814b2024-07-10 16:45:552024-07-10 16:45:59

Judging History

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

  • [2024-07-30 15:38:33]
  • hack成功,自动添加数据
  • (/hack/759)
  • [2024-07-10 16:45:59]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7660kb
  • [2024-07-10 16:45:55]
  • 提交

answer

#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;
const int N = 1e6 + 10;

int n, X, k, head, now = 1;
ll x = 1e9, y = 1, s;
int a[N], q[N], v[N];

ll gcd(ll x, ll y) {
	if(x == 0) return y;
	return gcd(y % x, x);
}

int main() {
	cin >> n >> X >> k;
	for(int i = 1; i <= k; ++i) cin >> a[i];
	for(int i = 0; i < n; ++i) v[i] = n + 1;
	v[X] = 0, q[++head] = X;
	while(now <= head) {
		int u = q[now++];
		for(int i = 1; i <= k; ++i) {
			int to = u + a[i];
			if(to >= n) to -= n;
			if(v[u] + 1 < v[to]) 
				v[to] = v[u] + 1, q[++head] = to;
		}
	}
	if(v[0] <= n) x = v[0];
	s = v[0];
	for(int i = 1; i <= n; s += v[i++]) 
		if(x * i > y * (s + n)) x = s + n, y = i;
	ll num = gcd(min(x, y), max(x, y));
	cout << x / num << ' ' << y / num;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 7660kb

input:

6 3 2
2 4

output:

29 6

result:

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