当前位置:网站首页>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;
}
边栏推荐
- JS shift operators (< <,> > and > > >)
- 八大排序
- Thinking about the arrangement problem in the backtracking problem (leetcode questions 46 and 47)
- QT learning 20 standard dialog box in QT (middle)
- Duet date picker (time plug-in that can manually enter the date)
- Raft agreement
- 泰凌冲刺科创板:拟募资13亿 国家大基金与小米长江是股东
- Exercise 8-2 calculate the sum and difference of two numbers
- 【吉林大学】考研初试复试资料分享
- jvm-类加载
猜你喜欢

Page generation QR code

Eight sorts
![[clean up the extraordinary image of Disk C]](/img/0d/331115bc5d82d6337ae975a08494b2.jpg)
[clean up the extraordinary image of Disk C]

Print. JS -- web page file printing

JVM runtime data area

Polestar美股上市:5.5万台交付如何支持得起超200亿美元估值

Exercise 9-1 time conversion

jvm-类加载

Nucleic acid modified metal organic framework drug carrier | pcn-223 metal organic framework encapsulated ad adamantane | zif-8 encapsulated adriamycin (DOX)

Leetcode(4)——尋找兩個正序數組的中比特數
随机推荐
虽然不一定最优秀,但一定是最努力的!
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.)
Redis: redis data structure and key operation commands
Raft agreement
Understanding of closures
npm install卡住与node-npy的各种奇怪报错
Formation of mil-100 (FE) coated small molecule aspirin [email protected] (FE) | glycyrrhetinic acid modified metal organ
Metal organic framework (MOFs) antitumor drug carrier | pcn-223 loaded with metronidazole | uio-66 loaded with ciprofloxacin hydrochloride(
Uio-66-cooh loaded bendamostine | hydroxyapatite (HA) coated MIL-53 (FE) nanoparticles | baicalin loaded manganese based metal organic skeleton material
必贝特医药冲刺科创板:年营收97万亏损1.37亿 拟募资20亿
JS Part III
NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
Collection of mobile adaptation related articles
7-9 find a small ball with a balance
simpleParallax. JS (create poor visual effects for website pictures)
7-7 12-24 hour system
修改数据库中的记录为什么报这个错
QT learning 19 standard dialog box in QT (top)
Selenium browser (1)
Scroll detection of the navigation bar enables the navigation bar to slide and fix with no content