Cdoj 3 Bilibili, Acfun ... and more! Problem Solving Report

Source: Internet
Author: User

Well, I still came back, after the competition did not touch the Unnamed.space, now has expired. The same few months did not touch Oi, hands are obviously unfamiliar many, graduated from the re-engage Oi, presumably dropped a lot.

College entrance Examination is very slag, but it is an honor to enroll in the University of a Pi county, a male technical school, so go to their OJ on the onlookers, casually do a few questions to play.

Well, do not mention, I say cdoj 3 of the general practice, very obvious pursuit of the problem, because the data is very small, \ (o (n) \) Violence can be, but the formula is to push the word (O (1) \) The practice.

I did not use violence here (I was done after the filming to the online search of violence ...). ), the formula is deduced from the beginning.

Because the topic is Kennethsnow look at the time, and look at the sample data can be obtained, the first T is not counted into the final result, at first did not notice the pit.

First consider the simple case, in \ (x<y\) and \ (ty>s\) when the results are obvious, the direct output \ (\frac{s}{x}\) is the answer.

We know that the first T-time loads the \ (ty\) data-I call it the No. 0 stage.

The 1th play will be time consuming \ (ty\times\frac{1}{x-y}\), this time will be loaded (ty\times\frac{x}{x-y}\) data--I call the 1th stage

The 2nd time it will be time to play (ty\times\frac{x}{(x-y) ^2}\), this time will be loaded (ty\times\frac{x^2}{(x-y) ^2}\) data-I call the 2nd stage

...... Similarly, it can be seen that playback time-consuming and loaded video are geometric series

The nth play will be time consuming \[ty\times\frac{x^{n-1}}{(x-y) ^n}\], if this time \ (>s/x\), means that the nth time has been loaded the entire video, the nth period of time is \ (s/x\)

And the inequalities above are \[ty\times\frac{x^{n-1}}{(x-y) ^n}>\frac{s}{x}\]

Solution to \[n=\left\lceil\log_{x/(x-y)}\frac{s}{ty}\right\rceil\]

Based on geometric series summation formula, total time \[\begin{align*}\sum&=\frac{ty}{x-y}\times\frac{\left (\frac{x}{x-y}\right) ^{n-1}-1}{\frac{X} {x-y}-1}+\frac{s}{x}\\&\\&=\frac{ty}{x-y}\times\frac{\left (\frac{x}{x-y}\right) ^{n-1}-1}{\frac{Y}{X-Y} }+\frac{s}{x}\\&\\&=t\left[\left (\frac{x}{x-y}\right) ^{n-1}-1\right]+\frac{s}{x}\end{align*}\]

...... The mathematical formula of the blog park is so ugly.

This time the answer has come out, and finally only need to turn it into code (gee, how I remember I have uploaded syntaxhighlighter in the blog park, how the files are missing). Suggest it or play it by yourself, because all the ideas of solving the problem are on it.

1#include <cstdio>2#include <cmath>3 using namespacestd;4 5 intT;6 Doublex, y, T, S;7 DoubleTime ;8 intN;9 Ten intMain () { Onescanf"%d", &T); A      for(intKase =1; Kase <= T; ++Kase) { -printf"Case #%d:", Kase); -scanf"%LF%LF%LF%LF", &x, &y, &t, &s); the         if(x > Y && T * y <s) { -n = ceil (log (S/(Y * t))/log (X/(X-( y) )); -Time = T * (POW (x/y), N-1) -1) + S/x; -printf"%.3lf\n", time); +}Elseprintf"%.3lf\n", S/x); -     } +     return 0; A}

Cdoj 3 Bilibili, Acfun ... and more! Problem Solving Report

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.