Magic (CSDN Programming Challenge)

Source: Internet
Author: User

Magic Topic Details:

You have 3 kinds of magic, you can use the first magic to turn a gram of sand into a B-gram metal, you can use the second magic to turn C-gram metal into d gram of gold, you can use a third magic to the e gram of gold into f g sand.

Ask if you can get unlimited gold with the initial limited amount of sand, metal, and gold?

Input format:

Multiple sets of data, with only one row per group containing input 6 integers a,b,c,d,e,f

(0<=a,b,c,d,e,f<=1000)

Output format:

Each set of output lines, yes and no indicate whether to get unlimited gold.



Answer instructions:

Input sample

100 200 250 150 200 250

100 50 50 200 200 100

1 1 0 1 1 1

100 1 100 1 0 1

Sample output:

YES

NO

YES

YES


It is required to be sentenced to 0 of the situation.

Code:

#include <cstdio> #include <cstring> #include <algorithm> #include <iostream>int main () {    int a,b,c,d,e,f;    while (~SCANF ("%d%d%d%d%d%d", &a,&b,&c,&d,&e,&f))    {        if (d==0) printf ("no\n");        else if (c==0) printf ("yes\n");        else if (b==0) printf ("no\n");        else if (a==0) printf ("yes\n");        else if (f==0) printf ("no\n");        else if (e==0) printf ("yes\n");        else if (b*d*f>a*c*e) printf ("yes\n");        else printf ("no\n");}    }


Magic (CSDN Programming Challenge)

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.