Submit | All submissions | Best solutions | Back to list |
ALCHE - Alchemy |
Alchemy is a discipline that is believed to span at least 2500 years of human history. It is most known for its intention of transforming matter, typically trying to come up with a recipe to make gold based on much less valued metals, aided by some non-metal components.
Most scientists and scholars think that alchemy has failed. They surely do not know that a particular alchemist named Albert Ainstain, managed to create gold from a simple combination of ordinary iron (much more common and cheap than gold) and some good- old-fashioned water. However, the combination must have the exact proportion of grams of iron and centiliters of water to work, otherwise the alchemist would end up with useless rusty iron.
Many alchemists and businessman had tried to recreate Albert Ainstain’s findings to achieve recognition, fame, prestige or economical welfare, but none of them have succeeded. Since you know very little about chemistry, alchemy and ancient practices, you believe that your chances for success in this task are bounded to using a computer in your benefit. Therefore, you decide to create a program that automatically tests a given combination of iron and water, and informs whether that combination has the correct proportion to produce gold. Of course, once you find the right proportion, you can double both amounts and get double the gold, cut both in half and get half the gold, or multiply both by any other real number to obtain the amount of gold you want. Your task is then, given the number of grams of iron and the number of centiliters of water, say whether the proportion between both components is the right one.
Input
The input contains several test cases, each one described in a single line. The line contains two integers I and W separated by a single space, representing grams of iron and centiliters of water, respectively (1 ≤ I, W ≤ 106). The last line of the input contains the number −1 twice separated by a single space and should not be processed as a test case.
Output
For each test case output a single line containing an uppercase “Y” if the combination produces gold, or an uppercase “N” otherwise.
Example
Input: 1000 37 999 37 10000 370 10001 370 -1 -1 Output: Y N Y N
Added by: | Pablo Ariel Heiber |
Date: | 2010-08-22 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: NODEJS OBJC PERL6 VB.NET |
Resource: | FCEyN UBA ICPC Selection 2009 |
hide comments
|
||||||
2017-07-22 11:52:47
nothing is given in problem.....but something is given in sample cases... |
||||||
2015-07-15 06:16:17
find gcd of two numbers .and divide numbers by gcd and if the divided numbers are (1000,37)then o/p Y else N use long long int c=gcd(a,b); a=a/c; b=b/c; if( (a==1000) && (b==37) ) printf("Y\n"); else printf("N\n"); ac in 1 go :D 0.0s |
||||||
2013-06-25 12:38:24 Shubham Gupta
same code got accepted in c++ but not in c why ??? is cin faster than scanf??? |
||||||
2013-02-16 09:20:13 reggaeguitar
Tip: If you are using doubles or floats, compare then by subtracting the smaller from the larger and comparing the difference to a very small number, like 1e-6 |
||||||
2012-06-02 02:13:25 Vrian7
The problem is very easy, just analize the first case |
||||||
2012-01-08 20:17:55 Amit Rai
i didn't get the question ........please help me out |
||||||
2012-01-01 10:57:49 Abhra
getting WA again and again used both (1000/37)==(w/i) and (37/1000)==(i/w) sol code #6278029... pls check |
||||||
2011-12-11 12:48:13 Shashank Shekhar Suri
Easy one :) |
||||||
2011-10-10 17:41:55 Varshneya
Aargh. Did everything right. Still getting WA. Working with integer arithmetic and on C. Sol code:5813181 |
||||||
2011-10-06 13:00:09 sri
very easy prob.. got ac on first try:) |