Submit | All submissions | Best solutions | Back to list |
BHAT007 - Nikhil Problem |
Nikhil is a very interesting and creative character. Nikhil had best friend whose name was Kasat. Kasat was inspired from SKG, a mathematics professor having an experience of 30 years of teaching in IIT Kanpur, So he decided to open Mathematics classes named as “SAI KRIPA GANIT BHANDAR”. But unfortunately no one joined his classes as the fees he charged was too low compared to other institutions, so people thought that he is not a good teacher and his wait for the students continued, but the best friend Nikhil was not able to see his friend Kasat in such a gloomy situation. So to boost Kasat’s spirit he became the only student of the “SAI KRIPA GANIT BHANDAR”.
Nikhil learned addition multiplication in different number system (like binary number system: base 2, octal number system: base 8, Hexagonal number system, Kasat number system : base 7, Shrotriya number system: base 3, bhat number system: base 13, rajnikant number system base: 100, ravikant number system base:101 etc. ).
Nikhil was given daily assignment on this but helping friends and being lazy are two different things, all he could help Kasat was to join coaching classes and completing those complex assignment were not his cup of tea. Kasat thought an innovative idea for Nikhil to sharp his mind in the field of number system. So, he gives the same type of problem daily in assignment.
Problem:
x(b1) + y(b1) = z1
x(b2) + y(b2) = z2
x(b): number x in base b number system .
x and y are two numbers (must be valid in decimal (i.e. base 10), base b1 and base b2 number system like 1A is not valid in base 10 i.e. decimal number system but valid in base 16, 17, 18, etc.)
z1 and z2 are the results of addition of x and y number in base b1 and b2 number system respectively .
If z1 and z2 are similar then answer is "yes" else "no".
0 <= x <= 2100
0 <= y <= 2100
1 < b1 <= 100
1 < b2 <= 100
Your task is to write the program to solve the problem of Nikhil.
Input
The input consists of T test cases. The number of them (T) is given on the first line of the input file. Each test case begins with a line containing four integers x, y (0 <= x, y <= 2100) and b1, b2 (1 < b1, b2 <= 100).
Output
Your program should print one line of output for each test case. Output can either be "yes" or "no" .
Example
Input: 3
10 01 2 10
11 11 2 10
12 12 8 10
Output:
yes
no
yes
Added by: | om |
Date: | 2011-07-24 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | inspired from interesting character of nikhil :) |
hide comments
|
|||||
2017-08-24 12:33:17
the bases are always greater than 1, not sure why statement has <=. |
|||||
2017-03-04 03:48:57 Medo
Test cases are very weak. I passed with 2 buggy solutions. |
|||||
2016-01-10 10:40:10 MAYANK NARULA
What do you mean by similar numbers ? How are 30(in base 8) and 24( in base 10) corresponding to last test-case similar strings? |
|||||
2014-12-10 10:12:45 rajul
way tooo easy.. came back after 5 months with a fresh mind and it's just a piece of cake :) |
|||||
2013-04-14 19:56:32 SudShekhar
Can someone please explain the testcases? |
|||||
2013-02-19 09:25:49 nikhil
i am the person on which this problem is based |
|||||
2012-05-31 13:51:16 jaans
nice q om :* |
|||||
2011-12-31 08:05:51 PubLic_AvenGeR
How to represent nos from 36-99 after Z??? |
|||||
2011-11-16 14:12:45 Andy
what's after "Z"? |