Advertisement
Guest User

Untitled

a guest
May 30th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.17 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.IO;
  4. using System.Text;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7.  
  8. /**
  9.  * Auto-generated code below aims at helping you parse
  10.  * the standard input according to the problem statement.
  11.  **/
  12. class Player
  13. {
  14.      static int SpeedSum(int a)
  15.         {
  16.             int sum=(1+a)*a/2;
  17.             return sum;
  18.         }
  19.        
  20.     static void Main(string[] args)
  21.     {
  22.         int road = int.Parse(Console.ReadLine()); // the length of the road before the gap.
  23.         int gap = int.Parse(Console.ReadLine()); // the length of the gap.
  24.         int platform = int.Parse(Console.ReadLine()); // the length of the landing platform.
  25.        
  26.         int OptimalSpeed = gap + 1;
  27.        
  28.         int PositionToSpeedUp = road - SpeedSum(OptimalSpeed)-4;
  29.         if (PositionToSpeedUp<0)
  30.         {
  31.             PositionToSpeedUp = 0;
  32.             }
  33.         bool jump = false; //jump has been performed indicator
  34.        
  35.         // game loop
  36.         while (true)
  37.         {
  38.             int speed = int.Parse(Console.ReadLine()); // the motorbike's speed.
  39.             int coordX = int.Parse(Console.ReadLine()); // the position on the road of the motorbike.
  40.  
  41.             // Write an action using Console.WriteLine()
  42.             // To debug: Console.Error.WriteLine("Debug messages...");
  43.  
  44.  
  45.             // A single line containing one of 4 keywords: SPEED, SLOW, JUMP, WAIT.
  46.         Console.Error.WriteLine("длина дороги: {0}",road);
  47.         Console.Error.WriteLine("пропасть: {0}",gap);
  48.         Console.Error.WriteLine("платформа: {0}",platform);
  49.         Console.Error.WriteLine("------------------------------------------------");
  50.        
  51.        
  52.         Console.Error.WriteLine("координаты: {0}",coordX);
  53.         Console.Error.WriteLine("когда газовать: {0}",PositionToSpeedUp);
  54.         Console.Error.WriteLine("скорость: {0}",speed);
  55.         Console.Error.WriteLine("оптимальная скорость: {0}",OptimalSpeed);
  56.          
  57.          
  58.          //starting point
  59.           if (coordX == 0 && speed == 0)
  60.          {
  61.              Console.WriteLine("SPEED");
  62.              continue;
  63.              }
  64.          
  65.      
  66.          if (road - 2  ==coordX )
  67.          {
  68.              Console.WriteLine("JUMP");
  69.               jump = true;
  70.               continue;    
  71.              }
  72.  
  73.          
  74.          if (coordX >= PositionToSpeedUp && speed < OptimalSpeed && jump ==false)
  75.          {
  76.              Console.WriteLine("SPEED");
  77.              continue;
  78.             }
  79.             else if (jump == true)
  80.             {
  81.                 Console.WriteLine("SLOW");
  82.                 continue;
  83.                 }
  84.             else
  85.             {
  86.                 Console.WriteLine("WAIT");
  87.                 continue;
  88.                 }
  89.        
  90.        
  91.        
  92.        
  93.         //speed 1 test block
  94.        
  95.         /*
  96.          if (coordX == 0 && speed == 0)
  97.          {
  98.              Console.WriteLine("SPEED");
  99.              }
  100.              Console.WriteLine("WAIT");
  101.        
  102.        
  103.        */
  104.         //Console.Error.WriteLine(road);
  105.  
  106.         }
  107.     }
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement