QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#520195#8008. Fortune Wheelhanmm81WA 43ms6080kbC++141.8kb2024-08-15 11:30:492024-08-15 11:30:50

Judging History

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

  • [2024-08-15 11:30:50]
  • 评测
  • 测评结果:WA
  • 用时:43ms
  • 内存:6080kb
  • [2024-08-15 11:30:49]
  • 提交

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(){
	cin >> n >> x >> k;
	for (int i = 1;i < n;i++) dist[i] = 0x3f3f3f3f;
	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.up > dist[x]*ans.down) ans = fen(dist[x]);
	cout << ans.up << " " << ans.down;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3572kb

input:

6 3 2
2 4

output:

8 3

result:

ok 2 number(s): "8 3"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

5 4 1
1

output:

1 1

result:

ok 2 number(s): "1 1"

Test #3:

score: 0
Accepted
time: 43ms
memory: 6080kb

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: 2ms
memory: 3824kb

input:

10000 23 7
9594 8998 9330 6851 1662 6719 583

output:

62031 6950

result:

wrong answer 1st numbers differ - expected: '42726', found: '62031'