Nyoj 949 Harry Potter (detail question)

Source: Internet
Author: User

Harry Potter time limit: +Ms | Memory Limit:65535KB Difficulty:3
Descriptive narrative

Harry learned three kinds of magic. He was able to use the first magic to turn a gram of sand into a B-gram metal, to use another kind of magic to turn C-gram metal into D-gram gold, and to use a third magic to turn e gram gold into F-gram sand. Ron and Hermione, two of Harry's best friends, were delighted, but Ron and Hermione had a disagreement, and Ron believed that Harry could gain unlimited gold with these three kinds of magic, Hermione that he could not get infinitely much. Harry wants to know exactly who's right.

Input
Enter a 6 integer a,b,c,d,e,f
(0<=a,b,c,d,e,f<=1000)
Output
The
output of who is right, assuming Ron is on the output "Ron". Otherwise output "Hermione"
Example input
100 200 250 150 200 250100 50 50 200 200 1001 1 0 1 1 1100 1 100 1 0 1
Example output
Ronhermioneronron
Uploaded by

Acm_ Wang Ying

Idea: Forward gold "reverse gold" (Ron)

Forward: K=b/c*d

Reverse: q= (k/e) *f

w= (q/a) *b

p= (w/c) *d//Reverse Gold

Be aware that the input can have 0 so

1.a=0 BCD time Infinite gold Ron C=0&&d infinitely change out of gold Ron

2. When (a=0| | c=0| | e=0) &&b, D, F are also infinite gold

3. When (a==0&&b==0) | | (e==0&&f==0) | | (c==0&&d==0) There is a link in the middle of herminoe that cannot be converted

(The SYY code is simpler than I wrote)


#include <stdio.h>int main () {    double a,b,c,d,e,f;    while (~SCANF ("%lf%lf%lf%lf%lf%lf", &a,&b,&c,&d,&e,&f))    {        if (c==0&&d)        {            printf ("ron\n");            Continue;        }        if (a==0&&b&&c&&d)        {            printf ("ron\n");            Continue;        }        if (a==0| | c==0| | e==0) (&&b&&d&&f)        {            printf ("ron\n");            Continue;        }        if ((a==0&&b==0) | | | (e==0&&f==0) | | (c==0&&d==0))        {            printf ("hermione\n");            Continue;        }        Double k= (b/c) *d;        Double q= (k/e) *f;        Double w= (q/a) *b;        Double p= (w/c) *d;        if (p>k)            printf ("ron\n");        else            printf ("hermione\n");    }    return 0;}  



Nyoj 949 Harry Potter (detail question)

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.