BFMUL - Farmer Joe
Farmer Joe is a strange fellow indeed. He owns a rare breed of cow that eats chocolate and produces chocolate milk, and each cow has exactly L legs. Lately, Joe has been suffering from sore feet, and his intuition tells him that it must be from the chocolate milk. The cows, he suspects, are in pain from stepping on sharp pebbles while crossing the road with chickens in their bare hooves. Naturally, they are transferring their pain karmically through the milk. So he has taken it upon himself to make proper hoofwear for all of them. As he lives at the top of an ivory tower, he finds it most convenient to count their heads. (Each cow has exactly one head.) Joe would like to know how many shoes he must make given that he has counted H heads, and in fact he wrote a program for just this purpose but can’t seem to find it. The program is written for a special computer that he constructed while he was writing his dissertation on Turing machines. He has asked for your help in replacing his program. Please help him quickly, so his cows can suffer as little as possible.
Note: You can use any programming language you want, as long as it is brainf**k.
Input
The first line contains an integer T (1 ≤ T ≤ 1000). Then follow T lines, each containing integers L and H (0 ≤ L,H ≤ 10^20) separated by a single space. Each line, including the last, is terminated by a single newline (linefeed) character, which has ASCII value 10.
Output
T lines containing the number of shoes Farmer Joe must make.
Example
Input:
5 0 0 0 42 42 0 42 42 12345 67890
Output:
0 0 0 1764 838102050
Additional Info
There are two randomly generated data sets, one with T=1000 and the other with T=500. L and H are generated independently, and the average number of digits in either is about 11.
My solution at the time of publication has 410 bytes (not golfed) and runs in 0.27s with 1.8M memory footprint.
hide comments
(Tjandra Satria Gunawan)(曾毅昆):
2013-07-06 12:22:25
Seems that I'm fastest for now ;-)
|
|
Smithers:
2013-06-23 02:49:20
*Phew*
|
|
Mostafa 36a2:
2013-06-20 18:37:14
Hah!! Look At My Last triple :D
|
|
Mostafa 36a2:
2013-06-20 14:26:11
@Mitch : Thanks For the feedBack
|
|
Mostafa 36a2:
2013-06-20 06:07:21
Hello Mitch ..
|
|
NARUTO (y):
2013-06-14 14:12:21
r u on facebook actually i want to be in contact with u for ur guidelines for programming if u have no problem then please give me ur facebook link
|
|
NARUTO (y):
2013-06-14 03:09:23
i don't know about brainf**K from where i can learn about this and please tell me it is easy language or hard as compare to c/c++
|
|
NARUTO (y):
2013-06-13 16:07:02
how to come out from tle
|
|
Akash:
2013-06-11 21:09:53
How do we take such large inputs in BF?
|
|
Vaibhav Sinha:
2013-06-08 18:11:51
If possible, allow other languages too.
|
Added by: | Mitch Schwartz |
Date: | 2013-06-01 |
Time limit: | 5s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | BF |