QOJ.ac
QOJ
ID | Submission ID | Problem | Hacker | Owner | Result | Submit time | Judge time |
---|---|---|---|---|---|---|---|
#757 | #469647 | #8008. Fortune Wheel | czc | xia_mc | Failed. | 2024-07-30 11:45:58 | 2024-07-30 11:45:58 |
Details
Extra Test:
Accepted
time: 0ms
memory: 3344kb
input:
1 0 1 1
output:
0 1
result:
ok 2 number(s): "0 1"
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#469647 | #8008. Fortune Wheel | xia_mc | AC ✓ | 51ms | 4392kb | C++14 | 1.9kb | 2024-07-09 21:28:37 | 2024-07-30 15:40:18 |
answer
#include<cstdio>
#include<algorithm>
//static char buf[1000000],*p1=buf,*p2=buf,obuf[1000000],*p3=obuf;
//#define getchar() p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++
//#define putchar(x) (p3-obuf<1000000)?(*p3++=x):(fwrite(obuf,p3-obuf,1,stdout),p3=obuf,*p3++=x)
template<typename dy> dy abs(dy x){return x>0?x:-x;}
template<typename dy> dy max(dy x,dy y){return x>y?x:y;}
template<typename dy> dy min(dy x,dy y){return x<y?x:y;}
template<typename dy> void swap(dy &x,dy &y){x^=y;y^=x;x^=y;}
template<typename dy>
void read(dy &x){
x=0;int f=1;char c=getchar();
while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
x*=f;
}
template<typename dy>
void write(dy x){
if(x<0){putchar('-');x=-x;}
if(x>9) write(x/10);
putchar(x%10+48);
}
void write(char x){putchar(x);}
void read(char *s){
while((*s=getchar())==' '||*s=='\n');
while((*++s=getchar())!=' '&&*s!='\n'&&*s!=EOF);
*s=0;
}
template<typename dy,typename... Args> void read(dy &x,Args &...args){read(x);read(args...);}
template<typename dy,typename... Args> void write(dy x,Args ...args){write(x);write(args...);}
#define int long long
const int N=1e5+5,inf=1e9;
int n,x,K,a[N],q[N],deep[N],id[N];
void bfs(int s){
int l=0,r=0;
q[r++]=s;deep[s]=1;
while(l<r){
int u=q[l++];
for(int i=1;i<=K;i++){
int v=u-a[i]+n>n?u-a[i]:u-a[i]+n;
if(!deep[v]){
q[r++]=v;
deep[v]=deep[u]+1;
}
}
}
for(int i=0;i<n;i++) if(!deep[i]) deep[i]=inf;else deep[i]--;
}
signed main(){
read(n,x,K);
for(int i=1;i<=K;i++) read(a[i]);
bfs(0);int sum=0;
for(int i=0;i<n;i++) id[i]=i;
std::sort(id,id+n,[](int x,int y){return deep[x]<deep[y];});
int ans1=deep[x],ans2=1;
for(int i=0;i<n;i++){
if(deep[id[i]]==inf) break;
sum+=deep[id[i]];
int u=sum+n,v=i+1;
if(ans1*v>ans2*u) ans1=u,ans2=v;
}
int t=std::__gcd(ans1,ans2);
write(ans1/t,' ',ans2/t);
return 0;
}