QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#469484#8008. Fortune WheelLYY_yyyyWA 21ms4260kbC++141.2kb2024-07-09 19:38:152024-07-09 19:38:15

Judging History

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

  • [2024-07-30 15:38:33]
  • hack成功,自动添加数据
  • (/hack/759)
  • [2024-07-10 08:02:33]
  • hack成功,自动添加数据
  • (/hack/730)
  • [2024-07-09 19:38:15]
  • 评测
  • 测评结果:WA
  • 用时:21ms
  • 内存:4260kb
  • [2024-07-09 19:38:15]
  • 提交

answer

#include<bits/stdc++.h>
#define lowbit(x) (x&(-x))
#define pb emplace_back
using namespace std;
struct node
{
	long long a,b;
	friend node operator + (const node &a,const node &b)
	{
		long long d=__gcd(a.b,b.b);
		return (node){a.a*b.b/d+b.a*a.b/d,a.b*b.b/d};
	}
	friend node operator * (const node &a,const node &b)
	{
		long long p=a.a*b.a,q=a.b*b.b,d=__gcd(p,q);
		return (node){p/d,q/d};
	}
	friend bool operator < (const node &a,const node &b)
	{
		return a.a*b.b<a.b*b.a;
	}
}; 
int p[510],dis[100010];
int d;
bool vis[100010];
int n,x,m;
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin>>n>>x>>m;
	for(int i=1;i<=m;i++) cin>>p[i];
	queue<int> s;memset(dis,0x3f,sizeof(dis));
	dis[0]=0;s.push(0);
	while(!s.empty())
	{
		int now=s.front();s.pop();
		if(vis[now]) continue;
		vis[now]=1;
		for(int i=1;i<=m;i++)
		{
			int to=(now-p[i]+n)%n;
			if(dis[to]>dis[now]+1) dis[to]=dis[now]+1,s.push(to);
		}
	}d=dis[x];node ans={dis[x],1};
	sort(dis,dis+n);node ss={0,1};
	for(int i=0;i<n;i++)
	{
		if(dis[i]>=d) break;
		ss=ss+(node){dis[i],1};
		ans=min(ans,(node){n,i+1}+(node){1,i+1}*ss);
	}
	cout<<ans.a<<" "<<ans.b;
	return 0;
}

详细

Test #1:

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

input:

6 3 2
2 4

output:

8 3

result:

ok 2 number(s): "8 3"

Test #2:

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

input:

5 4 1
1

output:

1 1

result:

ok 2 number(s): "1 1"

Test #3:

score: 0
Accepted
time: 21ms
memory: 4260kb

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: 0
Accepted
time: 0ms
memory: 4208kb

input:

10000 23 7
9594 8998 9330 6851 1662 6719 583

output:

42726 4805

result:

ok 2 number(s): "42726 4805"

Test #5:

score: 0
Accepted
time: 1ms
memory: 4192kb

input:

100 3 100
7 68 28 98 19 32 90 79 92 40 96 30 95 91 71 15 33 18 69 1 61 43 5 75 73 64 58 100 88 20 99 37 17 22 82 67 70 55 47 80 66 12 4 24 26 54 74 57 21 77 86 89 83 29 46 31 2 16 49 48 25 93 52 9 85 84 42 39 8 65 10 45 63 87 78 60 23 14 34 59 81 38 41 76 3 13 27 36 35 51 44 62 53 94 6 50 11 97 72 56

output:

1 1

result:

ok 2 number(s): "1 1"

Test #6:

score: -100
Wrong Answer
time: 0ms
memory: 3996kb

input:

100 93 4
63 58 3 89

output:

285 60

result:

wrong answer 1st numbers differ - expected: '19', found: '285'