当前位置:网站首页>7-22 tortoise and rabbit race (result oriented)
7-22 tortoise and rabbit race (result oriented)
2022-07-03 14:14:00 【Big fish】
The tortoise is racing with the rabbit , The track is a rectangular track , The edge of the runway can rest anywhere . 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 Minutes back to see the tortoise , If you find yourself more than a turtle , Just rest on the side of the road , Every break 30 minute , Or 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 time , Excuse me, T Minutes later, who is the tortoise and the rabbit ?
Input format :
Enter the time of the game on one line T( minute ).
Output format :
Output the results of the game in one line : The tortoise wins the output @[email protected], Rabbit wins output ^_^, A draw is a draw -_-; Heel 1 Space , Then output the distance that the winner ran .
sample input :
242
sample output :
@[email protected] 726Ideas :
There are three possibilities : Tortoise wins 、 Rabbit wins 、 It ends in a draw . Because the tortoise is only in motion , And rabbits have two kinds of movement and stillness , So the rabbit wins 、 The draw is divided into the rabbit winning the game , The rabbit wins in stillness , Draw in sports , Static Draw .
#include <iostream>
using namespace std;
int main(){
int bunny = 0, turtle = 0;
int T;
cin >> T;
int t = 0;
int rest = 0; // The rabbit still needs to rest
while(t < T){
turtle += 3; // Tortoise runs every minute 3m
if(t % 10 == 0 && bunny > turtle && rest == 0){ // Judge whether the rabbit wants to rest
rest = 30;
}
if(rest != 0) // The rabbit is resting
rest --;
else
bunny += 9;
t++;
}
if(bunny == turtle)
printf("-_- %d", bunny);
else if(bunny > turtle)
printf("^_^ %d", bunny);
else
printf("@[email protected] %d", turtle);
return 0;
}
边栏推荐
- 必贝特医药冲刺科创板:年营收97万亏损1.37亿 拟募资20亿
- jvm-运行时数据区
- Too many files with unapproved license
- Exercise 7-6 count capital consonants
- js 2023. String pair equal to the target string after connection
- Article content typesetting and code highlighting
- Exercise 9-3 plane vector addition
- 7-8 overspeed judgment
- 7-2 and then what time (15 minutes)
- Exercise 8-8 moving letters
猜你喜欢
随机推荐
Strategy, tactics (and OKR)
消息订阅与发布
How to bold text in AI
Formation of mil-100 (FE) coated small molecule aspirin [email protected] (FE) | glycyrrhetinic acid modified metal organ
JS continues to explore...
7-6 mixed type data format input
7-7 12-24 hour system
Exercise 9-3 plane vector addition
Metal organic framework material zif-8 containing curcumin( [email protected] Nanoparticles) | nano metal organic framework carry
中国PETG市场预测及战略研究报告(2022版)
JS download files through URL links
GRPC的四种数据流以及案例
[acnoi2022] guess numbers
7-17 crawling worms (break exercise)
剑指 Offer 28. 对称的二叉树
Print. JS -- web page file printing
jvm-运行时数据区
How to delete an attribute or method of an object
Too many files with unapproved license
Raft 协议









