当前位置:网站首页>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;
}
边栏推荐
- 虽然不一定最优秀,但一定是最努力的!
- Programmable logic device software testing
- Exercise 8-7 string sorting
- Scroll detection of the navigation bar enables the navigation bar to slide and fix with no content
- Raft agreement
- fpga阻塞赋值和非阻塞赋值
- 28: Chapter 3: develop Passport Service: 11: define attributes in the configuration file, and then obtain them in the code;
- JS download files through URL links
- Why don't I have a rookie medal
- Sendmail无法发送邮件及发送过慢解决
猜你喜欢

愉悦资本新双币基金近40亿元完成首次关账

Exercise 6-6 use a function to output an integer in reverse order

QT learning 25 layout manager (4)

Exercise 6-2 using functions to sum special A-string sequences

Leetcode(4)——尋找兩個正序數組的中比特數

“又土又穷”的草根高校,凭什么被称为“东北小清华”?

7-10 calculate salary

28: Chapter 3: develop Passport Service: 11: define attributes in the configuration file, and then obtain them in the code;

JS input number and standard digit number are compared. The problem of adding 0 to 0

NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
随机推荐
Toast UI editor (editor allows you to edit your markup document using text or WYSIWYG, with syntax highlighting, scrolling synchronization, real-time preview and chart functions.)
allegro,orcad, net alias,port,off-page connector之间的异同点和如何选取
Exercise 6-6 use a function to output an integer in reverse order
全文检索引擎Solr系列—–全文检索基本原理
28:第三章:开发通行证服务:11:在配置文件中定义属性,然后在代码中去获取;
JS Part III
7-6 mixed type data format input
7-8 overspeed judgment
7-17 crawling worms (break exercise)
Configure stylelint
全局事件总线
fpga阻塞赋值和非阻塞赋值
八大排序
TS code automatically generates JS
[Jilin University] information sharing of postgraduate entrance examination and re examination
Duet date picker (time plug-in that can manually enter the date)
Doxorubicin loaded on metal organic framework MIL-88 DOX | folic acid modified uio-66-nh2 doxorubicin loaded [email
MongoDB索引
JVM垃圾回收机
Leetcode(4)——寻找两个正序数组的中位数