QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#520175 | #8008. Fortune Wheel | hanmm81 | WA | 1ms | 4492kb | C++14 | 1.8kb | 2024-08-15 11:19:00 | 2024-08-15 11:19:00 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
#include <bits/stdc++.h>
#define int long long
using namespace std;
struct fen{
int up,down;
fen(int p=0,int q=1){
int t = __gcd(p,q);
p /= t,q /= t;
up = abs(p),down = abs(q);
if (p * q < 0) up = -up;
}
double show(){
return 1.0*up/down;
}
bool operator>(const fen & a){
return (up*a.down > a.up*down);
}
bool operator<(const fen & a){
return (up*a.down < a.up*down);
}
fen operator+(const fen & a){
return fen(a.up*down+up*a.down,down*a.down);
}
fen operator+=(const fen & a){
return *this = fen(a.up*down+up*a.down,down*a.down);
}
fen operator-(const fen & a){
return fen(up*a.down-a.up*down,down*a.down);
}
fen operator-=(const fen & a){
return *this = fen(up*a.down-a.up*down,down*a.down);
}
fen operator*(const fen & a){
return fen(a.up*up,down*a.down);
}
fen operator*=(const fen & a){
return *this = fen(a.up*up,down*a.down);
}
fen operator/(const fen & a){
return fen(a.down*up,a.up*down);
}
fen operator/=(const fen & a){
return *this=*this/a;
}
}ans;
int dist[100005],n,x,k,a[505],cnt;
priority_queue<pii> p;
signed main(){
memset(dist,0x3f,sizeof(dist));
cin >> n >> x >> k;
for (int i = 1;i <= k;i++) cin >> a[i];
dist[0] = 0,p.push({0,0});
while (!p.empty()){
pii top = p.top();
p.pop();
for (int i = 1;i <= k;i++){
if (dist[(top.se-a[i]+n)%n] > 1-top.fi) p.push(make_pair(-(dist[(top.se-a[i]+n)%n] = 1-top.fi),(top.se-a[i]+n)%n));
}
}
for (int i = 0;i < n;i++){
if (dist[i] < dist[x]) ans += fen(dist[i]),cnt++;
}
ans += fen(n),ans /= fen(cnt);
if (ans > fen(dist[x])) ans = fen(dist[x]);
cout << ans.up << " " << ans.down;
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 4492kb
input:
6 3 2 2 4
output:
4557430888798830399 1
result:
wrong answer 1st numbers differ - expected: '8', found: '4557430888798830399'