QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#467200#8008. Fortune Wheelljy_qojRE 0ms3872kbC++141.9kb2024-07-08 15:04:482024-07-08 15:04:49

Judging History

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

  • [2024-07-30 15:38:33]
  • hack成功,自动添加数据
  • (/hack/759)
  • [2024-07-10 08:02:33]
  • hack成功,自动添加数据
  • (/hack/730)
  • [2024-07-08 15:04:49]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3872kb
  • [2024-07-08 15:04:48]
  • 提交

answer

#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<chrono>
#include<climits>
#include<cmath>
#include<complex>
#include<condition_variable>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<mutex>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<random>
#include<regex>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<strstream>
#include<thread>
#include<type_traits>
#include<typeinfo>
#include<unordered_map>
#include<utility>
#include<vector>
#define int long long
using namespace std;

int n, x, k, z, m, now;
int a[510], stp[510];
queue<int> q;

int gcd(int a, int b) {
	if (b == 0)
		return a;
	return gcd(b, a % b);
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n >> x >> k;
	for (int i = 1; i <= k; i++) {
		cin >> a[i];
		a[i] %= n;
	}
	for (int i = 1; i < n; i++) {
		stp[i] = LLONG_MAX;
	}
	q.push(0);
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		for (int i = 1; i <= k; i++) {
			int v = (u - a[i] + n) % n;
			if (stp[v] == LLONG_MAX) {
				stp[v] = stp[u] + 1;
				q.push(v);
			}
		}
	}
	z = min(stp[x], n);
	m = 1;
	sort(stp + 1, stp + n + 1);
	for (int i = 1; i < n; i++) {
		if (stp[i] == LLONG_MAX) {
			break;
		}
		now += stp[i];
		now %= n;
		if ((now + n) * m < z * i) {
			z = now + n;
			m = i;
		}
	}
	int d = gcd(z, m);
	z /= d;
	m /= d;
	cout << z << ' ' << m;

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6 3 2
2 4

output:

8 3

result:

ok 2 number(s): "8 3"

Test #2:

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

input:

5 4 1
1

output:

1 1

result:

ok 2 number(s): "1 1"

Test #3:

score: -100
Runtime Error

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:


result: