Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class HelloWorld {
- static void Main() {
- int length = int.Parse(Console.ReadLine());
- int time = int.Parse(Console.ReadLine());
- int distance = CalculateDistance(length, time);
- Console.WriteLine(distance);
- }
- static int CalculateDistance(int corridor, int Time){
- int cycles = Time / (2 * corridor);
- int remaningTime = Time % (2 * corridor);
- int distance = (remaningTime <= corridor) ? remaningTime : 2 * corridor - remaningTime;
- return distance;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement