Blue Bridge Cup BASIC 24 turtle and Rabbit Race Prediction (analogue)

Source: Internet
Author: User

"Idea": simulation. Note that one is the time when the hare rested the turtle could have arrived. I didn't think about wa80% at the beginning.

"AC Code":

#include <iostream> #include <algorithm> #include <iomanip> #include <cstdio> #include < Cstring>using namespace Std;int Main () {//freopen ("In.txt", "R", stdin);//freopen ("OUT.txt", "w", stdout); int v1 = 0, V 2 = 0, t = 0, s = 0, L = 0;int len_t = 0, Len_r = 0, cnt = 0, i = 0;cin >> v1 >> v2 >> t >> s > > L;while (True) {Cnt++;len_r + = v1;len_t + = v2;if (Len_r = len_t && len_t = = L) {cout << "D" << End L << Cnt;return 0;} else if (len_t = = L) {cout << "T" << Endl << cnt;return 0;} else if (Len_r = = L) {cout << "R" << Endl << cnt;return 0;} if (len_r-len_t >= t) {//cnt + = s;//len_t + = v2*s;for (i = 1; I <= s; i++) {cnt++;len_t + = v2;if (Len_r = len_t &am p;& len_t = = L) {cout << "D" << Endl << cnt;return 0;} else if (len_t = = L) {cout << "T" << Endl << cnt;return 0;} else if (Len_r = = L) {cout << "R" << Endl << Cnt;return 0;}}}}} 


Blue Bridge Cup BASIC 24 turtle and Rabbit Race Prediction (analogue)

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.