QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#527116#8008. Fortune WheelChrysanthBlossomWA 107ms7288kbC++141.6kb2024-08-22 10:24:592024-08-22 10:25:00

Judging History

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

  • [2024-08-22 10:25:00]
  • 评测
  • 测评结果:WA
  • 用时:107ms
  • 内存:7288kb
  • [2024-08-22 10:24:59]
  • 提交

answer

#include<bits/stdc++.h> 
#define ri register int
#define ll long long
#define mkp make_pair
#define ld long double 
using namespace std;
const int maxn=1e5+7;
int n,x,K;
int k[maxn];
int f[maxn];
const int inf=1e9;
int a[maxn];
struct Frac{
	ll fz,fm;
	Frac () {}
	Frac (ll a,ll b=1):fz(a),fm(b){
		if(fm<0)fm=-fm,fz=-fz;
		ll g=__gcd(abs(a),abs(b));
		fz/=g;fm/=g;
	}
	friend Frac operator + (Frac a,Frac b){return Frac(a.fz*b.fm+a.fm*b.fz,a.fm*b.fm);}
	friend Frac operator - (Frac a,Frac b){return Frac(a.fz*b.fm-a.fm*b.fz,a.fm*b.fm);}
	friend Frac operator * (Frac a,Frac b){return Frac(a.fz*b.fz,a.fm*b.fm);}
	friend Frac operator / (Frac a,Frac b){return Frac(a.fz*b.fm,a.fm*b.fz);}
	friend bool operator < (Frac a,Frac b){return (a-b).fz<0;}
	friend bool operator > (Frac a,Frac b){return (a-b).fz>0;}
	friend bool operator == (Frac a,Frac b){return (a-b).fz==0;}
	friend bool operator <= (Frac a,Frac b){return !(a>b);}
	friend bool operator >= (Frac a,Frac b){return !(a<b);}
	void print_fs(){cout<<fz<<' '<<fm;}
	void print(){cout<<(ld)(fz)/(ld)(fm);}
};
vector<int>vec[maxn];
void bfs(){
	queue<int>q;
	q.push(0);
	while(!q.empty()){
		int u=q.front();q.pop();
		for(ri i=1;i<=K;i++){
			int v=(u-k[i]+n)%n;
			if(f[v]>f[u]+1){
				f[v]=f[u]+1;
				q.push(v);
			}
		}
	}
}
signed main(){
	ios::sync_with_stdio(0);
	cin>>n>>x>>K;
	for(ri i=1;i<=K;i++)cin>>k[i];
	memset(f,0x3f,sizeof(f));
	f[0]=0;
	bfs();
	for(ri i=0;i<n;i++)a[i]=f[i];
	sort(a,a+n);
	Frac ans=Frac(f[x]);
	ll sum=0;
	for(ri i=0;i<n;i++){
		sum+=a[i];
		ans=min(ans,(Frac(sum)/Frac(i+1))+(Frac(n)/Frac(i+1)));
	}
	ans.print_fs();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6 3 2
2 4

output:

8 3

result:

ok 2 number(s): "8 3"

Test #2:

score: 0
Accepted
time: 1ms
memory: 7188kb

input:

5 4 1
1

output:

1 1

result:

ok 2 number(s): "1 1"

Test #3:

score: 0
Accepted
time: 42ms
memory: 6936kb

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

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: 1ms
memory: 7288kb

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: 1ms
memory: 6556kb

input:

100 93 4
63 58 3 89

output:

19 4

result:

ok 2 number(s): "19 4"

Test #7:

score: 0
Accepted
time: 20ms
memory: 6684kb

input:

75057 45721 3
10861 27551 14278

output:

32797 933

result:

ok 2 number(s): "32797 933"

Test #8:

score: 0
Accepted
time: 29ms
memory: 6648kb

input:

97777 94043 1
83579

output:

97619 221

result:

ok 2 number(s): "97619 221"

Test #9:

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

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: 22ms
memory: 6796kb

input:

77777 64477 3
45863 40922 74543

output:

298537 8416

result:

ok 2 number(s): "298537 8416"

Test #11:

score: 0
Accepted
time: 1ms
memory: 6776kb

input:

1 0 1
1

output:

0 1

result:

ok 2 number(s): "0 1"

Test #12:

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

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

input:

33 32 6
20 26 25 18 5 28

output:

101 32

result:

ok 2 number(s): "101 32"

Test #14:

score: 0
Accepted
time: 47ms
memory: 6740kb

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:

13953 2000

result:

ok 2 number(s): "13953 2000"

Test #15:

score: 0
Accepted
time: 70ms
memory: 7048kb

input:

100000 88341 500
35014 85376 26718 27010 22158 56540 54016 52932 81956 92630 79862 844 37070 30304 9780 50642 56332 91384 20562 17764 94836 28314 23928 46364 59128 5820 21488 60066 5262 8964 53054 28310 79006 92364 20872 34916 10934 56274 1020 23138 70610 85702 56844 99122 56842 8772 61584 5346 4819...

output:

40687 10000

result:

ok 2 number(s): "40687 10000"

Test #16:

score: 0
Accepted
time: 107ms
memory: 6784kb

input:

100000 80536 500
91882 33957 97622 44074 36850 17254 63750 32583 12125 43292 58710 2227 31892 64531 13775 20782 72858 85509 37363 57708 26191 2037 8279 5828 38370 88145 76527 73627 28868 68151 31497 78935 1779 63126 37781 57818 46131 81930 43171 25281 1175 90726 12883 73954 7094 46278 62218 33972 54...

output:

2 1

result:

ok 2 number(s): "2 1"

Test #17:

score: -100
Wrong Answer
time: 30ms
memory: 6768kb

input:

100000 14944 4
76800 80400 34400 91600

output:

-7862388088316251732 9999800001

result:

wrong answer 1st numbers differ - expected: '101433', found: '-7862388088316251732'