QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#470871 | #8008. Fortune Wheel | Rose_Lu | WA | 1ms | 7660kb | C++14 | 814b | 2024-07-10 16:45:55 | 2024-07-10 16:45:59 |
Judging History
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;
}
详细
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'