Xtu summer individual 6 B-number busters

Source: Internet
Author: User
Number busterstime limit: 1000 msmemory limit: 262144 kbthis problem will be judged on codeforces. Original ID: 382b
64-bit integer Io format: % i64d Java class name: (any) Arthur and Alexander are number Busters. Today they 've got a competition.

 

Arthur took a group of four IntegersA, Bytes,B, Bytes,W, Bytes,X(0 bytes ≤ bytesBLatency <latencyW, When 0 then <thenXLatency <latencyW) And Alexander took integerBytes. Arthur and Alexander use distinct approaches to number bustings. Alexander is just a regular guy. Each second, he subtracts one from his number. In other words, he performs the assignment:CSignature = SignatureCExample-Example 1. Arthur is a sophisticated guy. Each second Arthur performs a complex operation, described as follows: ifBLimit ≥ limitX, Perform the assignmentBSignature = SignatureBAccept-Encoding-X, IfBLatency <latencyX, Then perform two consecutive assignmentsASignature = SignatureAAccept-limit 1;BSignature = SignatureWAudio-extract -(XAccept-Encoding-B).

You 've got numbersA, Bytes,B, Bytes,W, Bytes,X, Bytes,C. Determine when Alexander gets ahead of Arthur if both guys start making the operations at the same time. Assume that Alexander got ahead of Arthur ifCLimit ≤ limitA.

Input

The first line contains IntegersA, Bytes,B, Bytes,W, Bytes,X, Bytes,C(1 digit ≤ DigitALimit ≤ limit 2 · 109, limit 1 limit ≤ limitWLimit ≤ limit 1000, limit 0 limit ≤ limitBLatency <latencyW, When 0 then <thenXLatency <latencyW, Memory 1 ≤ memoryCLimit ≤ limit 2-109 ).

Output

Print a single integer-the minimum time in seconds Alexander needs to get ahead of Arthur. You can prove that the described situation always occurs within the problem's limits.

Sample inputinput
4 2 3 1 6
Output
2
Input
4 2 3 1 7
Output
4
Input
1 2 3 2 6
Output
13
Input
1 1 2 1 1
Output
0
Sourcecodeforces round #224 (div. 2) Problem Solving: Assuming c '= c-t after T times; a' = A-N; B' = B-Tx + NW; after the c '<= A' is solved, there is: (WC-wa-B + B')/(W-x) <= t because t needs to be rounded up, and the minimum value is, therefore, when B 'is equal to 0, T has a minimum lower bound ....
 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cstdlib> 5 #include <vector> 6 #include <climits> 7 #include <algorithm> 8 #include <cmath> 9 #define LL long long10 #define INF 0x3f3f3f11 using namespace std;12 double a,b,w,x,c;13 int main(){14     while(~scanf("%lf %lf %lf %lf %lf",&a,&b,&w,&x,&c)){15         double ans = ceil((w*c-w*a-b)/(w-x));16         printf("%.0f\n",c<=a?0:ans);17     }18     return 0;19 }
View code

 

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.