QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#467198#8008. Fortune Wheelljy_qojCompile Error//C++141.8kb2024-07-08 15:02:222024-07-08 15:02:22

Judging History

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

  • [2024-07-30 15:38:33]
  • hack成功,自动添加数据
  • (/hack/759)
  • [2024-07-10 08:02:33]
  • hack成功,自动添加数据
  • (/hack/730)
  • [2024-07-08 15:02:22]
  • 评测
  • [2024-07-08 15:02:22]
  • 提交

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;

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;
}

詳細信息

In file included from /usr/include/c++/13/backward/strstream:50,
                 from answer.code:46:
/usr/include/c++/13/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated. [-Wcpp]
   32 | #warning \
      |  ^~~~~~~
answer.code: In function ‘int main()’:
answer.code:97:17: error: ‘_Gcd’ was not declared in this scope
   97 |         int d = _Gcd(z, m);
      |                 ^~~~