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)