Advertisement
UraniumGames

Гарри Поттер и спасение Сириуса Блэка

Nov 26th, 2023
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | Writing | 0 0
  1. using System;
  2.  
  3. class HelloWorld {
  4.   static void Main() {
  5.     int length = int.Parse(Console.ReadLine());
  6.     int time = int.Parse(Console.ReadLine());
  7.    
  8.     int distance = CalculateDistance(length, time);
  9.    
  10.     Console.WriteLine(distance);
  11.   }
  12.    
  13.   static int CalculateDistance(int corridor, int Time){
  14.     int cycles = Time / (2 * corridor);
  15.    
  16.     int remaningTime = Time % (2 * corridor);
  17.     int distance = (remaningTime <= corridor) ? remaningTime : 2 * corridor - remaningTime;
  18.    
  19.     return distance;
  20.    
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement