SNGFRAC1 - Adding Two Fractions
Given two fractions, just add them. Too Easy :)
The fractions are represented either as p/q or p such that q >= 1. Now let p1/q1 and p2/q2 be the given fractions, then the sum of the fractions will either be P/Q or P (that allows the fraction to be in irreducible form).
The fraction given as p is equal to p/1.
Input
The first line of input is T, (total no. of test cases). Next T lines contains two space separated fractions.
Output
Print the sum of two fractions (must be in irreducible form) in most appropriate format in each line.
Example
Input: 5 1/2 1/3 2 -1/2 2/4 4/8 -1/7 1/11 -21/7 -31/1 Output: 5/6 3/2 1 -4/77 -34
Constraints
T <= 10000
-109 <= p <= 109
1 <= q <= 109
Irreducible Fraction
The fraction p/q is said to be in irreducible form if greatest common divisor of "p" and "q" is 1.
hide comments
|
AvmnuSng:
2014-06-22 12:02:55
@Mitch : I will surely take care of it and one last thing, if you say I can allow all the languages for submission but without compromising with the initially set time limits for test cases.
|
|
Mitch Schwartz:
2014-06-22 12:02:55
I don't really see the logic of restricting to those particular languages, but at some point I run out of energy to make arguments and reach an agreement when there are seemingly incompatible viewpoints. I seem to have solved it in an acceptable way now (until the next rejudge...), and anyway I've made the problem visible again (in classical section). Please try to be more careful when setting new problems, to avoid inconveniences on all ends. Thank you. |
|
Mitch Schwartz:
2014-06-22 12:02:55
There are some other issues as well. The problem is not fair for slower languages, and my guess is that you did this intentionally to exclude languages that have certain built-in features that would make the problem quite trivial. (Maybe my initial submission had something to do with this?) A more direct approach seems better: only allow some languages. You can see e.g. GCD4 where there is a justified language restriction. Last edit: 2014-06-21 00:17:58 |
|
AvmnuSng:
2014-06-22 12:02:55
I understand that rejudge is rare and must be done with proper notice, but there were just two users submitted so I rejudged the submissions and the reason for rejudge is just the extra test cases I was adding, as I told you earlier. |
|
Mitch Schwartz:
2014-06-22 12:02:55
It's very simple. When you publish a problem, you are inviting other users to spend their time working on it. They may do so, with the general intent of getting a favorable judge result. If they succeed, they will tend to get a sense of satisfaction, to varying degrees. Changing the problem after people have already spent time on it can cause a feeling that is somewhat opposite to satisfaction.
|
|
AvmnuSng:
2014-06-22 12:02:55
@Mitch : The rejudge was done because I was adding test cases. and now I am done... So I hope you will allow submissions for the problem now. Last edit: 2014-06-20 23:31:36 |
|
Mitch Schwartz:
2014-06-22 12:02:55
Problem hidden because problem setter is incompetent.
|
Added by: | AvmnuSng |
Date: | 2014-06-20 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
Resource: | Abhimanyu Singh My Problems |