Cycle-18. Turtle and Rabbit Race (20)

Source: Internet
Author: User

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 "@[email protected]", the Rabbit wins output "^_^", the draw output "-_-", followed by 1 spaces, and then output the winner run out of distance.

Input Sample:

242

Sample output:

@[email protected] 726

#include <iostream> #include <stdio.h> #include <math.h> #include <string>int main () {int t;     scanf ("%d", &t); int i=0;int rabbit=0;int tortoise=0;int wait=30;int run=10;int mode=0;    while (i<t) {i++;            tortoise+=3;    if (mode==0)//rabbit is in run mode {if (run>0) {rabbit+=9;   run--; printf ("Run%d Rabbit%d tortoise%d\n", run,rabbit,tortoise);}  else//10 minutes to {if (rabbit>tortoise)//detect whether beyond {mode=1;//beyond the rest of the wait=29;  printf ("Wait%d rabbit%d tortoise%d\n", wait,rabbit,tortoise);  } else//not go beyond, continue to run {mode=0;  run=9;    rabbit+=9;  printf ("Run%d Rabbit%d tortoise%d\n", run,rabbit,tortoise); }}}else {if (wait>0) {wait--;//rest//printf ("Wait%d rabbit%d tortoise%d\n", wait,rabbit,tortoise);}    else{mode=0;run=9;rabbit+=9;//printf ("Run%d Rabbit%d tortoise%d\n", run,rabbit,tortoise);}}    } if (rabbit>tortoise) printf ("^_^%d", rabbit);    else if (rabbit==tortoise) printf ("-_-%d", rabbit); else printf ("@[email pRotected]%d ", tortoise); return 0;}

  

Cycle-18. Turtle and Rabbit Race (20)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.