QOJ.ac
QOJ
ID | 提交记录ID | 题目 | Hacker | Owner | 结果 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|
#756 | #470948 | #8008. Fortune Wheel | czc | Zi_Gao | Failed. | 2024-07-30 11:45:09 | 2024-07-30 11:45:09 |
详细
Extra Test:
Accepted
time: 1ms
memory: 3980kb
input:
1 0 1 1
output:
0 1
result:
ok 2 number(s): "0 1"
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#470948 | #8008. Fortune Wheel | Zi_Gao | AC ✓ | 91ms | 4324kb | C++14 | 1.4kb | 2024-07-10 17:00:23 | 2024-07-30 15:41:31 |
answer
#include<bits/stdc++.h>
// #define ONLINE_JUDGE
#define INPUT_DATA_TYPE long long
#define OUTPUT_DATA_TYPE long long
inline __attribute((always_inline)) INPUT_DATA_TYPE read(){register INPUT_DATA_TYPE x=0;register char f=0,c=getchar();while(c<'0'||'9'<c)f=(c=='-'),c=getchar();while('0'<=c&&c<='9')x=(x<<3)+(x<<1)+(c&15),c=getchar();return f?-x:x;}void print(OUTPUT_DATA_TYPE x){if(x<0)x=-x,putchar('-');if(x>9)print(x/10);putchar(x%10^48);return;}
int K[510],dis[100010];
int main(){
#ifndef ONLINE_JUDGE
freopen("name.in", "r", stdin);
freopen("name.out", "w", stdout);
#endif
register int i,u,v;
register long long resa,resb,sum=0,gcd;
int n=read();
int x=read();
int m=read();
for(i=0;i<m;++i) K[i]=read();
std::queue<int> q;
memset(dis,0x3f,sizeof(dis));
dis[0]=0;
q.push(0);
while(!q.empty()){
u=q.front(),q.pop();
for(i=0;i<m;++i)
if(dis[v=(u+n-K[i])%n]==0x3f3f3f3f)
dis[v]=dis[u]+1,q.push(v);
}
resa=dis[x],resb=1;
sum=n;
std::sort(dis,dis+n);
for(i=1;i<=n;++i){
sum+=dis[i-1];
if(resa*i>resb*sum)
resa=sum,resb=i;
}
gcd=std::__gcd(resa,resb);
resa/=gcd,resb/=gcd;
print(resa),putchar(' '),print(resb),putchar(' ');
#ifndef ONLINE_JUDGE
fclose(stdin);
fclose(stdout);
#endif
return 0;
}