QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#470584#8008. Fortune WheelsqrtqwqWA 21ms4204kbC++14936b2024-07-10 15:17:532024-07-10 15:17:53

Judging History

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

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

answer

#include<bits/stdc++.h>
// #define int long long
using namespace std;

const int maxn = 1e5 + 10;
int to[maxn],dis[maxn];long long ansZ,ansM;

void update(long long zi,long long mu)
{
	long double ans = ansZ / ansM,now = zi / mu;
	if(now < ans)
	{
		int g = __gcd(zi,mu);
		mu /= g,zi /= g;
		ansM = mu;
		ansZ = zi;
	}
}

signed main()
{
	int n,x,k;cin >> n >> x >> k;
	for(int i = 1;i <= k;i++)cin >> to[i];
	
	queue<int> q;
	memset(dis,63,sizeof(dis));
	dis[0] = 0;
	q.push(0);
	while(!q.empty())
	{
		int u = q.front();q.pop();
		for(int i = 1;i <= k;i++)
		{
			int v = (u - to[i] + n) % n;
			if(dis[u] + 1 < dis[v])
			{
				dis[v] = dis[u] + 1;
				q.push(v);
			}
		}
	}
	ansZ = dis[x],ansM = 1;
	sort(dis,dis + n);
	for(int i = 0;i < n && dis[i] < 1e9;i++)
	{
		dis[i] += (!i ? 0 : dis[i - 1]);
		update(n + dis[i],i + 1);
	}
	cout << ansZ << " " << ansM << '\n';
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3992kb

input:

6 3 2
2 4

output:

8 3

result:

ok 2 number(s): "8 3"

Test #2:

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

input:

5 4 1
1

output:

1 1

result:

ok 2 number(s): "1 1"

Test #3:

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

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: 4204kb

input:

10000 23 7
9594 8998 9330 6851 1662 6719 583

output:

38582 4287

result:

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