QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#471294#8008. Fortune WheelLZL1251212203RE 481ms167940kbC++141.2kb2024-07-10 20:23:042024-07-10 20:23:05

Judging History

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

  • [2024-07-30 15:38:33]
  • hack成功,自动添加数据
  • (/hack/759)
  • [2024-07-10 20:23:05]
  • 评测
  • 测评结果:RE
  • 用时:481ms
  • 内存:167940kb
  • [2024-07-10 20:23:04]
  • 提交

answer

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
const int N=2e7+10;
int n,bg,m;
int skl[N];
struct edge{
	int nxt,to;
}e[N];
int head[N],tot,all;
void add(int u,int v){
	e[++tot].nxt=head[u];
	e[tot].to=v;
	head[u]=tot;
}
int d[N];
double res;
double up,dw,sum[N];
bool vis[N];
void bfs(int x) {
	queue<int> q;
	q.push(x);
	d[0]=0;
	while(!q.empty()) {
		int x=q.front();
		q.pop();
		for(int i=head[x];i;i=e[i].nxt) {
			int to=e[i].to;
			if(!vis[to]) {
				vis[to]=1;
				d[to]=d[x]+1;
				q.push(to);
			}
		}
	}
}
int gcd(int x,int y){
	if(!y) return x;
	return gcd(y,x%y);
}
int main(){
	cin>>n>>bg>>m;
	memset(d,0x3f,sizeof(d));
	for(int i=1;i<=m;i++) cin>>skl[i];
	for(int i=1;i<n;i++) {
		for(int j=1;j<=m;j++) add((i+skl[j])%n,i);
	}
	bfs(0);
	up=res=d[bg];
	sort(d+1,d+n);
	for(int i=n;i>=2;i--) d[i]=d[i-1];
	d[1]=0;
	for(int i=1;d[i]!=1061109567&&i<=n;i++) {
		sum[i]=sum[i-1]+d[i];
		all++;
	}
	dw=1;
	for(int i=1;i<=all;i++) {
		if((double)(n+sum[i])/i < res) {
			res=(double)(n+sum[i])/i;
			up=n+sum[i];
			dw=i;
		}
	}
	int g=gcd(up,dw);
	cout<<up/g<<" "<<dw/g;
	return 0;
}
/*
6 3 2
2 4

5 4 1
1
*/

详细

Test #1:

score: 100
Accepted
time: 4ms
memory: 87876kb

input:

6 3 2
2 4

output:

8 3

result:

ok 2 number(s): "8 3"

Test #2:

score: 0
Accepted
time: 4ms
memory: 89736kb

input:

5 4 1
1

output:

1 1

result:

ok 2 number(s): "1 1"

Test #3:

score: 0
Accepted
time: 481ms
memory: 167940kb

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: 10ms
memory: 90120kb

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

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

input:

100 93 4
63 58 3 89

output:

19 4

result:

ok 2 number(s): "19 4"

Test #7:

score: 0
Accepted
time: 4ms
memory: 90484kb

input:

75057 45721 3
10861 27551 14278

output:

32797 933

result:

ok 2 number(s): "32797 933"

Test #8:

score: 0
Accepted
time: 8ms
memory: 90708kb

input:

97777 94043 1
83579

output:

97619 221

result:

ok 2 number(s): "97619 221"

Test #9:

score: 0
Accepted
time: 10ms
memory: 87804kb

input:

13515 10596 5
11890 9097 4596 13464 13309

output:

6022 489

result:

ok 2 number(s): "6022 489"

Test #10:

score: 0
Accepted
time: 3ms
memory: 91860kb

input:

77777 64477 3
45863 40922 74543

output:

298537 8416

result:

ok 2 number(s): "298537 8416"

Test #11:

score: 0
Accepted
time: 4ms
memory: 85928kb

input:

1 0 1
1

output:

0 1

result:

ok 2 number(s): "0 1"

Test #12:

score: 0
Accepted
time: 7ms
memory: 92060kb

input:

11254 5306 33
4933 97 3341 7991 766 11039 6490 8955 10986 642 421 4570 9198 3221 9106 5076 8660 517 8376 4918 10847 10400 9063 8416 4673 7139 3925 7192 8391 7763 4927 10373 3726

output:

3 1

result:

ok 2 number(s): "3 1"

Test #13:

score: 0
Accepted
time: 3ms
memory: 87748kb

input:

33 32 6
20 26 25 18 5 28

output:

101 32

result:

ok 2 number(s): "101 32"

Test #14:

score: -100
Runtime Error

input:

100000 56979 500
6945 45095 52485 23545 72920 30450 64925 31700 11155 65550 80965 77885 97915 26950 86940 50045 46645 74740 35235 13470 18315 72135 25260 88775 4405 25525 61335 97040 13240 2905 37460 51605 2330 54995 17100 30790 68205 53195 63340 85495 48535 94865 87720 52930 30650 47115 68380 24455...

output:


result: