HDU 4823 Energy Conversion structure

Source: Internet
Author: User

Title Link: HDU-4823

A magician has a problem when he has a small degree
Now, hundred degrees in front of an ancient stone gate, the stone Gate has an ancient magic words, read this magic words need to spend a lot of energy and a lot of brain power.
After a long time, hundred degrees finally read the meaning of magic words: There is a stone in Shek Mun, the magician need to through magic to circle the stone X-degree, so that the above the engraved lines and the sky, in order to open the shimen.
However, the rotation of the stone plate requires an n-point energy value, and in order to decipher the ciphertext, the energy value of the small degree only left M point! It is impossible to destroy a stone gate because it will require more energy. Fortunately, however, as a magician's hundred degrees can consume v-point energy, making his energy into the current of the remaining energy of the K-Fold (Wizard of the world you never understand, no one knows how he did it). For example, now that the A-V has a point energy, then he can turn his energy into a *k point (the energy cannot be negative at any time, i.e. if A is less than V, it cannot perform the conversion).
However, in the process of deciphering the ciphertext, the hundred-degree advance his IQ, so he now does not know whether he can rotate the stone plate, open the Shimen, can you help him?

Inputinput data The first line is an integer t, which indicates an example containing a T group test specimen;
Next is the T-line data, each line has 4 natural number n,m,v,k (character meaning see title description);
Data range:
t<=100
n,m,v,k <= 10^8Output

For each set of data, output at least a few times the energy conversion to be able to have enough energy point to open the door;
If this is not possible, please output-1 directly.

Test Instructions Description: Chinese title, as described above.

Algorithm analysis: This is the 2014 Baidu star qualifying game of a water problem, directly do, no algorithm.

1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cstdlib>5#include <cmath>6#include <algorithm>7 #defineINF 0x7fffffff8 using namespacestd;9typedefLong LongLL;Ten  One LL n,m,v,k; A  - intMain () - { the     intT; -scanf"%d",&t); -      while(t--) -     { +scanf"%i64d%i64d%i64d%i64d",&n,&m,&v,&k); -         if(m>=n) {printf ("0\n");Continue; } +         if(M&LT;=V) {printf ("-1\n");Continue; } A         intCnt=0, flag=0; at          while(m<N) -         { -             intA=m; -m= (M-V) *K; -CNT + + ; -             if(M==a | | m<=v) {flag=1;p rintf ("-1\n"); Break; } in         } -         if(!flag) printf ("%d\n", CNT); to     } +     return 0; -}

HDU 4823 Energy Conversion structure

Related Article

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.