The fairy Prince escaped from the cave

Source: Internet
Author: User

The Elf Prince loves Adventure, and in an adventure he enters a mysterious cave. In the depths of the cave, the elf Prince accidentally touched the hidden organs in the cave,
The cave will soon collapse, and the fairy Prince must flee the cave as soon as possible. The Elf Prince runs at a speed of 17m/s and may not escape from the caves at such a rate. Fortunately,
The elf prince has a flashing spell that moves 60m within 1s, but consumes 10 points each time a flashing spell is used. The magic value of the Elf Prince recovers at a speed of 4 points/s, which can only be resumed when resting in situ.
Now known as the Elf Prince's magical initial value m, the location of the cave in which he is located is the distance between the cave exit S, and the time t from the cave collapse. Your task is to write a program to help the Elf Prince calculate how to escape the caves in the shortest possible time.
If you can escape, output "Yes", and output the shortest time to escape, if not escape, then output "No", and output the fairy Prince in the remaining time to walk the farthest distance. Note The letter is case-sensitive.
Note that the Elf Prince runs, flashes or breaks in seconds (s). and the duration of each activity is an integer second. The unit of distance is in meters (m). Note: m,s,t are integers greater than or equal to 0. The input guarantees the legitimacy of the value, the examinee does not check.
Reminder: If the input S is 0, then the description itself is already in the export, the output should be: Yes 0 if the input t is 0 (and S is not 0), then it is no time, the output should be: no 0
Input format:
M
S
T
Output format:
Yes
The time it took to escape the caves

Or
No
The farthest distance you can escape before the cave collapses.

#include <iostream> #include <stdio.h> using namespace std;
   int main () {int m,s,t;
   scanf ("%d%d%d", &m,&s,&t);
   int de1=0,de2=0;
   int start=t;
   BOOL Flag=false;
   if (s==0) cout<< "YES 0" <<endl;
       else {if (t==0) cout<< "NO 0" <<endl;
                else {while (T) {t--;
                    if (m>=10) {m-=10;
                de1+=60;
                }else {m+=4;
                } de2+=17;
                if (de2<de1) {de2=de1;
                  } if (de2>s) {cout<< "YES" <<start-T<<endl;
                  Flag=true;
              Break
            }} if (!flag) {cout<< "NO" <<de2<<endl;
 }      }} return 0;
 }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.