Submit | All submissions | Best solutions | Back to list |
ACFRAC - Another Continuous Fractions Problem |
The problem description is the same as the problem CFRAC and CFRAC2.
Input & Output
Multiple test cases, a single line with a single uppercase character C indicates the end of the input. The number of test cases will be less than 1000.
For each test case:
The first line of the input contains a single uppercase character A or B.A denotes that the input following character A and output format of this test case is the same as problem CFRAC, otherwise the input following character B and output format of this test case is the same as problem CFRAC2. But please pay attention that: the width and the height of the image after the character B will not appear in the input; the original fraction will not appear in the output of the test case of type A.
The example will make everything clear.
Example
Input: A 75 34 B ..........1...... 2.+.------------- ............1.... ....4.+.--------- ..............1.. ........1.+.----- ................1 ............5.+.- ................1 C Output: Case 1: ..........1...... 2.+.------------- ............1.... ....4.+.--------- ..............1.. ........1.+.----- ................1 ............5.+.- ................1 Case 2: 75 34
Added by: | Fudan University Problem Setters |
Date: | 2007-11-01 |
Time limit: | 4s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: C99 ERL JS-RHINO |
Resource: | XX Colombian National Programming ACM 2006, test data by Blue Mary |
hide comments
2019-07-11 08:46:01
p !=q for all cases of type A. Still, p > q exists in testdata as opposed to CFRAC, but the statement doesn't specify what to output there. For cases like 30 10, print: ....1 2.+.- ....1 Don't complain about this being hard in C. A pythonist on SPOJ has to deal with idiotic time limits, malformed inputs, implicit casting of results to 32-bit integer etc. every day while you get "AC in 1 go!!!1" without ever noticing the issues. And don't even start with me about having to add "irrelevant code"; half of the C code I've ever written deals with stupid stuff a programmer should never have to worry about. Just learn some Python and experience the fun of handling a problem like this with it. |
|
2014-04-04 17:01:32 Bharath Reddy
If we solve CFRAC and CFRAC2 in Python, then this is very simple.. We can just combine the two |
|
2013-01-08 09:18:13 (Tjandra Satria Gunawan)(曾毅昆)
@Santiago Palacio: I agree with you, the constraints is not clear and need big int to solve this... I think it's already hard to solve even with constraints p and q < 2^64... now I still can't solve this problem because p and q > 2^64 (overflow)... |
|
2013-01-08 05:26:07 Santiago Palacio
Why would you have to put those constraints? (p,q can be >= 2^64). That just limits some languages or creates the absolutely innesesary need of using code that isn't relevant to this problem... just my opinion. Last edit: 2013-01-08 05:26:25 |
|
2012-06-02 19:57:27 (Tjandra Satria Gunawan)(曾毅昆)
There are 2 types of tricky test case on this problem: 1) p==q 2) p>2^64 and q>2^64 I'm getting WA, i can't solve this problem, because it's always overflow :( |