QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#470942 | #8008. Fortune Wheel | Zi_Gao | WA | 1ms | 4252kb | C++14 | 1.4kb | 2024-07-10 16:59:17 | 2024-07-10 16:59:18 |
Judging History
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[(u+n-K[i])%n]==0x3f3f3f3f)
dis[(u+n-K[i])%n]=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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 4252kb
input:
6 3 2 2 4
output:
8 3
result:
ok 2 number(s): "8 3"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3996kb
input:
5 4 1 1
output:
1 1
result:
ok 2 number(s): "1 1"
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 4192kb
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:
100099 101
result:
wrong answer 1st numbers differ - expected: '3', found: '100099'