Submission #124478

#TimeUsernameProblemLanguageResultExecution timeMemory
124478DJ035물통 (KOI17_bucket)C++14
100 / 100
3 ms380 KiB
#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)

bucket.cpp:4:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
bucket.cpp: In function 'int main()':
bucket.cpp:5:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d%d",&a,&b,&c,&d);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...