# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
124478 | DJ035 | 물통 (KOI17_bucket) | C++14 | 3 ms | 380 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<stdio.h>
int a, b, c, d;
int a1, b1, cn1, cn2;
main() {
scanf("%d%d%d%d",&a,&b,&c,&d);
if(a==c && b==d){printf("2");return 0;}
do{
if(b1==b)b1=0;
else if(a1==0)a1=a;
else {if(a1+b1<b){b1+=a1;a1=0;}else {a1-=(b-b1);b1=b;}}
cn1++;
if(a1==c && b1==d)cn2=cn1;
}while(a1+b1>0);
if(cn2==0)printf("-1");
else printf("%d",(cn1-cn2<cn2?(cn1-cn2):cn2));
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |