<> Title Description

The tortoise ran a race with the rabbit , The running field is a rectangular track , You can rest anywhere near the runway . The tortoise can move forward every minute 3 rice , Rabbits advance every minute 9 rice ; The rabbit thinks the tortoise is slow , I think I can beat the tortoise , therefore , Every run 10 I'll look back at the tortoise , If you find yourself surpassing the tortoise , Just rest on the side of the road , Every break 30 minute , Otherwise, keep running 10 minute ; And the tortoise worked very hard , Keep running , Have no rest . Suppose the tortoise and the rabbit start at the same starting point and at the same time , Excuse me? T Who runs faster, tortoise or rabbit ?

<> Input format ：

Enter the match time in one line T（ minute ）.

<> Output format ：

Output the result of the game in one line ： Tortoise wins output @_@, Rabbit wins output ^_^, A draw is an output -_-; Heel 1 Space , Then output the distance the winner has run .

<> sample input ：
242
<> sample output ：
@_@ 726

thinking ： Simple simulation of the process of the tortoise and rabbit race , Because the tortoise runs all the time , So it's good for the tortoise's journey , Therefore, the problem is mainly to deal with the process of rabbit running . Let's set up one rest and run, among rest Time for rabbits to rest ,run It means the time the rabbit runs , Define another trigger flag,flag by 1 The rabbit is resting ,flag by 0 The rabbit is running , Judge every ten minutes , If the tortoise is ahead, keep running , At the same time run Set up 0, If the tortoise is in the back, it will flag Set up 1, At the same time run Set up 0. The last thing to note is that , Whether there is a winner or not , We need to output the distance that the winner runs , Including a draw .
#include <iostream> #include <cstdio> using namespace std; int main() { int t,
flag,rest,run; int a,b; cin >>t; a=0;b=0;flag=0;rest=0;run=0; while(t--){ if(run
==10){ // The rabbit ran for ten minutes to judge if(b>=a) flag=1; run=0; } a+=3; if(!flag){ // Rabbit running b+=9; run
++; } else{ // Rabbit rest rest++; if(rest==30){ flag=0; rest=0; } } } if(a==b) cout <<
"-_- "<<a<<endl; else if(a>b) cout <<"@_@ "<<a<<endl; else cout <<"^_^ "<<b<<
endl; return 0; }

Technology
Daily Recommendation