当前位置:网站首页>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] 726
Ideas :
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;
}
边栏推荐
- Redis: operation command of string type data
- Raft agreement
- Learn to punch in today
- JS first summary
- Solution to failure or slow downloading of electron when electron uses electron builder to package
- Zabbix添加Calculated items后保存页面成空白
- Leetcode (4) - - trouver la médiane de deux tableaux ordonnés positifs
- jvm-对象生命周期
- JVM class loading
- [Jilin University] information sharing of postgraduate entrance examination and re examination
猜你喜欢
天图投资冲刺港股:资产管理规模249亿 投了小红书与奈雪
556. 下一个更大元素 III
Scroll detection, so that the content in the lower right corner is not displayed at the top of the page, but is displayed as the mouse slides
7-15 calculation of PI
Why are grass-roots colleges and universities with "soil and poverty" called "Northeast small Tsinghua"?
关于回溯问题中的排列问题的思考(LeetCode46题与47题)
Exercise 10-8 recursive implementation of sequential output of integers
Solution to failure or slow downloading of electron when electron uses electron builder to package
protobuf与grpc
Uio-66-cooh loaded bendamostine | hydroxyapatite (HA) coated MIL-53 (FE) nanoparticles | baicalin loaded manganese based metal organic skeleton material
随机推荐
Too many files with unapproved license
TS code automatically generates JS
Folic acid modified metal organic framework (zif-8) baicalin loaded metal organic framework composite magnetic material (AU- [email
Reflection -- basic usage
7-7 12-24 hour system
Duet date picker (time plug-in that can manually enter the date)
小项目(servelt+jsp+mysql+EL+JSTL)完成一个登录功能的Servlet,具有增删改查的操作。实现登录身份验证,防止非法登录,防止多点登录,记住用户名密码功能。
FPGA test method takes mentor tool as an example
剑指 Offer 28. 对称的二叉树
Exercise 10-1 calculate the sum of 1 to n using recursive functions
Exercise 8-2 calculate the sum and difference of two numbers
Zabbix添加Calculated items后保存页面成空白
npm install卡住与node-npy的各种奇怪报错
LNMP环境mail函数不能发送邮件解决
中感微冲刺科创板:年营收2.4亿净亏1782万 拟募资6亿
7-14 sum integer segments (C language)
Scroll detection, so that the content in the lower right corner is not displayed at the top of the page, but is displayed as the mouse slides
Generate directories from web content
QT learning 17 dialog box and its types
Understanding of closures