QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#735525 | #7781. Sheep Eat Wolves | Suhy# | WA | 0ms | 1648kb | C++17 | 977b | 2024-11-11 20:31:25 | 2024-11-11 20:31:26 |
Judging History
answer
#include<cstdio>
int x,y,p,q;//sheep,wolf,seat,,safe right
int gans(){
y-=q;
if(y<=0)return 2*((x+p-1)/p)-1;
if(x<=p)return 1;
if(x-p+y-p<=p)return 3;
if(y-p<=x&&(p>>1)+p>=x)return 5;
int P=p;
if(y-q>x)p-=y-q-x,y-=y-q-x;
if(y-p>x)return -1;
if(p<=0)return -1;
int ans=0;
if(x<y){
++ans;
if(y-q==x){
y-=q;
x-=(p-q)>>1;
y-=(p-q)>>1;
q=0;
}else{
int k=y-x;
y-=k;q-=k;
x-=(p-k)>>1;
y-=(p-k)>>1;
if((p-k)&1)--x,--q;
}
}
while(x){
++ans;
if(x<=P)x=0;
else{
x-=p>>1;
y-=p>>1;
if((p&1)){
if(q)--y,--q;
else --x,++q;
}
}
}
return 2*ans-1;
}
int main(){
scanf("%d%d%d%d",&x,&y,&p,&q);
printf("%d",gans());
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 1464kb
input:
4 4 3 1
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 0ms
memory: 1604kb
input:
3 5 2 0
output:
5
result:
ok 1 number(s): "5"
Test #3:
score: 0
Accepted
time: 0ms
memory: 1648kb
input:
2 5 1 1
output:
-1
result:
ok 1 number(s): "-1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 1608kb
input:
1 1 1 0
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 1612kb
input:
3 3 1 1
output:
9
result:
wrong answer 1st numbers differ - expected: '7', found: '9'