Advertisement
KDOXG

URI Online Judge | 1964 (Presentation Error)

Mar 14th, 2020
495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.38 KB | None | 0 0
  1. /*
  2.  *  URI Online Judge | 1964
  3.  *  Author: Kaio KDOXG
  4.  *  Federal University of Pelotas, 2020
  5.  *
  6.  */
  7.  
  8. #include <stdio.h>
  9. #define A "Ana"
  10. #define B "Bia"
  11.  
  12. int main()
  13. {
  14.     unsigned long long Pa, Pb;          //A's and B's position
  15.     unsigned long long i;               //Iterator
  16.     unsigned choice;                    //Final choice
  17.  
  18.     unsigned long long C;
  19.     unsigned long long Va, Vb;
  20.     unsigned long long T;
  21.     unsigned long long D;
  22.  
  23.     scanf("%llu%llu%llu%llu%llu", &C, &Va, &Vb, &T, &D);
  24.  
  25.     if (C == 0 || C > 1000)
  26.         return 0;
  27.     if (Va == 0 || Va > 400)
  28.         return 0;
  29.     if (Vb == 0 || Vb > 400)
  30.         return 0;
  31.     if (T > 200)
  32.         return 0;
  33.     if (D >= C)
  34.         return 0;
  35.  
  36.     Pa = D; Pb = D;
  37.     T *= 60;                    //Minutes to seconds
  38.     Va /= 100; Vb /= 100;       //Centimeters to meters
  39.  
  40.     for (i=100; i<T; i++)
  41.     {
  42.         Pa += Va;
  43.         if (Pa >= C)
  44.             Pa -= C;
  45.         Pb += Vb;
  46.         if (Pb >= C)
  47.             Pb -= C;
  48.     }
  49.  
  50.     while (1)
  51.     {
  52.         Pa += Va;
  53.         Pb += Vb;
  54.         if (Pa >= C || Pb >= C)
  55.         {
  56.             choice = Pb > Pa ? 1 : 0;
  57.             break;
  58.         }
  59.     }
  60.  
  61.     switch(choice)
  62.     {
  63.         case 0:
  64.             printf("%s", A);
  65.             break;
  66.         case 1:
  67.             printf("%s", B);
  68.             break;
  69.     }
  70.  
  71.     return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement