QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#469876 | #8008. Fortune Wheel | dieselhuang | WA | 12ms | 4644kb | C++14 | 811b | 2024-07-10 08:35:44 | 2024-07-10 08:35:44 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, X, k, a[510], dis[100010], q[100010];
ll gcd(ll x, ll y){return x<y?gcd(y,x):(y>0?gcd(y,x%y):x);}
int main()
{
int i, u, v, st = 1, nd = 0, cnt = 0;
ll s = 0, x, y;
scanf("%d%d%d", &n, &X, &k);
for(i = 1; i <= k; i++) scanf("%d", &a[i]);
for(i = 0; i < n; i++) dis[i] = n + 1;
dis[X] = 0; q[++nd] = X;
while(st <= nd){
u = q[st++];
for(i = 1; i <= k; i++){
v = u + a[i];
if(v >= n) v -= n;
if(dis[u] + 1 < dis[v]){
dis[v] = dis[u] + 1; q[++nd] = v;
}
}
}
if(dis[0] <= n) printf("%d 1", dis[0]);
else{
for(i = 0; i < n; i++){
if(dis[i] <= n){
cnt++; s += dis[i];
}
}
x = s + n; y = cnt;
printf("%lld %lld", x / gcd(x, y), y / gcd(x, y));
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3956kb
input:
6 3 2 2 4
output:
8 3
result:
ok 2 number(s): "8 3"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3960kb
input:
5 4 1 1
output:
1 1
result:
ok 2 number(s): "1 1"
Test #3:
score: 0
Accepted
time: 12ms
memory: 4644kb
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: 1ms
memory: 4028kb
input:
10000 23 7 9594 8998 9330 6851 1662 6719 583
output:
10 1
result:
wrong answer 1st numbers differ - expected: '42726', found: '10'