QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#304803#8008. Fortune Wheelucup-team992#WA 184ms4716kbC++111.2kb2024-01-14 03:28:272024-01-14 03:28:27

Judging History

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

  • [2024-07-30 15:38:33]
  • hack成功,自动添加数据
  • (/hack/759)
  • [2024-07-10 08:02:33]
  • hack成功,自动添加数据
  • (/hack/730)
  • [2024-01-14 03:28:27]
  • 评测
  • 测评结果:WA
  • 用时:184ms
  • 内存:4716kb
  • [2024-01-14 03:28:27]
  • 提交

answer

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

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

int main() {
	ll N, X, K;
	cin >> N >> X >> K;
	vector<ll> Ks(K);
	for(int i = 0; i < K; i++) cin >> Ks[i];

	vector<ll> DP(N, 500*N);
	DP[0] = 0;
	for(int k = 0; k < K; k++) {
		int g = gcd(N, Ks[k]);
		for(int i0 = 0; i0 < g; i0++) {
			for(int c = i0, cc = 0; cc < 2*N/g; cc++, c = (c + N - Ks[k])%N) {
				DP[c] = min(DP[(c+Ks[k])%N]+1, DP[c]);
			}
		}
		//for(int i = 0; i < 2*N; i++)  DP[i%N] = min(DP[(i+Ks[k])%N] + 1, DP[i%N]);
		//for(int i = 2*N; i >= 0; i--) DP[i%N] = min(DP[(i+Ks[k])%N] + 1, DP[i%N]);
	}

	//for(int i = 0; i < DP.size(); i++) cout << DP[i] <<" "; cout << endl;

	vector<ll>DP0(DP);

	sort(DP.begin(), DP.end());



	int dpi = 0;
	int ksum = 0;

	int ct = min(DP0[X], N);
	int cb = 1;

	for(int c = 0; c <= N; c++) {
		while(dpi < N && DP[dpi] <= c) ksum += DP[dpi++];
		int t = ksum + N;
		int b = dpi;
		int g = gcd(t,b);
		//cout << c << " " << t << " " << b << std::endl;
		t /= g;
		b /= g;


		if(t*cb < b*ct) {
			ct= t;
			cb = b;
		}
	}

	cout << ct << " " << cb << std::endl;

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6 3 2
2 4

output:

8 3

result:

ok 2 number(s): "8 3"

Test #2:

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

input:

5 4 1
1

output:

1 1

result:

ok 2 number(s): "1 1"

Test #3:

score: 0
Accepted
time: 184ms
memory: 4716kb

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

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: 0ms
memory: 3604kb

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

input:

100 93 4
63 58 3 89

output:

19 4

result:

ok 2 number(s): "19 4"

Test #7:

score: -100
Wrong Answer
time: 9ms
memory: 4412kb

input:

75057 45721 3
10861 27551 14278

output:

2609017 37528

result:

wrong answer 1st numbers differ - expected: '32797', found: '2609017'