The tortoise and the Rabbit race, the running field is a moment-type runway, the runway side can rest everywhere. Turtle can advance 3 meters per minute, the rabbit forward 9 meters per minute, the hare too slow to run, feel sure can run to win the Turtle, so, every 10 minutes to look back at the turtle, if found himself over the turtle, on the roadside rest, every rest 30 minutes, or continue to run 10 minutes; Suppose the tortoise and the Hare start at the same time at the same starting point, may I ask the tortoise and the rabbit to run fast after T minute?
Input format:
Enter the race time t (minutes) in a row.
Output format:
Output the result of the match in one row: The Turtle wins the output, the @[email protected]
rabbit wins the output ^_^
, the draw is output, -_-
followed by 1 spaces, and the winner runs out of the distance.
Input Sample:
242
Sample output:
@[email protected] 726
Import Java.util.scanner;public class main{public static void Main (string[] args) {Scanner sc = new Scanner (system.in); int t = 0, G = 0;//t the distance g for the hare to run the distance int t = sc.nextint ();//input time//Total 4 in the case when the time >0 cycle the following 4//1. Rabbit after turtle (including distance equal) time >10min rabbit distance +90 turtle distance +30 time -10;//2. Rabbits in the turtle (including distance equal) time <10min rabbit distance +9*t turtle distance +3*t time =0;//3. Rabbit before turtle time >=30min rabbit distance +0 turtle distance +90 time -30;//4. Rabbit in front of turtle time <30min rabbit distance +0 turtle distance +3*t time =0; if (t>10) {while (t>0) {if (t<=g&&t>=10) { t+=90; g+=30; t-=10; } else if (t>g&&t>=30) {t+=0; g+=90; t-=30; } else if (t<=g&&t<10) {t+=9*t; G+=3*t; T = 0; } else if (t>g&&t<30) {t+=0; G+=3*t; t=0; }}//output of the result if (t<g) {System.out.println ("@[email protected]" +g); } else if (t>g) {SYSTEM.OUt.println ("^_^" +t); } else{System.out.println ("-_-" +t); }} else if (t==0) {//time equals 0 separate processing System.out.println ("-_-" +t); } else if (t>0&&t<=10) {///time less than 10 minutes is also handled separately System.out.println ("^_^" +9*t); } }}
Pat-java-5-22 Turtle and Rabbit race (20 min)