QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#470152 | #8008. Fortune Wheel | Rose_Lu | RE | 0ms | 3636kb | C++14 | 825b | 2024-07-10 10:58:45 | 2024-07-10 10:58:45 |
Judging History
answer
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 510;
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];
sort(v, v + n), 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: 100
Accepted
time: 0ms
memory: 3636kb
input:
6 3 2 2 4
output:
8 3
result:
ok 2 number(s): "8 3"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
5 4 1 1
output:
1 1
result:
ok 2 number(s): "1 1"
Test #3:
score: -100
Runtime Error
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...