Magic (csdn programming challenge) and magic csdn programming challenge

Source: Internet
Author: User

Magic (csdn programming challenge) and magic csdn programming challenge
Magic question details:

You have three types of magic. You can use the first magic to convert a gram of sand into B grams of metal. You can use the second magic to turn c grams of metal into d grams of gold, you can use the third magic to turn e-grams of gold into f-grams of sand.

Can you use the limited amount of sand, metal, and gold to get an unlimited amount of gold?

Input Format:

Multiple groups of data, each group has only one row containing six integers a, B, c, d, e, f

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

Output Format:

Each group outputs a row. "YES" and "NO" indicate whether there can be an infinite amount of gold.

Q & A description:

Input example

100 200 250 150 200 250

100 50 50 200 200 100

1 1 0 1 1 1

100 1 100 1 0 1

Output example:





The value must be set to 0.


#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");    }}

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: 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.