I use Python function .isdigit() to check if fraction is integer, but strings like "-12" gives False for .isdigit() check. So, in test 26 one of the fractions is something like -x, where x is integer. Edited by author 31.07.2024 13:33 Hi, I tried all the tests can be found in that discussion. My program gives always the right answers. I am using Python, so, there can't be any integer overflow. I am using gcd function from Fractions.
I rewrote my Python3 program in C++. It got AC immediately. Please somebody give test 36 || some hint to pass this test! Thank you very much! Edited by author 02.01.2011 17:54 Please help me! WA #36 is a result of something like 11 + 12 --> 23 0/1 I threw away the 0/1 part for such cases and got AC. My AC solution gives wrong answer for this test case: 1/2 - 1/3 my answer: -1/6 Add this test... try this test: 11 + 11 ##### 22 I have WA #30, but on all tests and on same tests my solution give right answers. Can be there others tricks? Hello! The code works correctly. Checked on many examples. Most likely something with input-output. Prompt, where it is wrong and how it is better to make fraction input? Code C++ Sorry for Russian comments //структура дроби struct Fractional { //объявление целой части, числителя и знаменателя long long intPart, numerator, denomerator; } _oneFract, _twoFract, _result; //функция считывания дроби Fractional ReadFractional() { Fractional _fract; //переменная _razdel определяет, что ввели: только целую часть, только дробную часть или целую и дробную часть char _razdel; //считываем первое число scanf("%lld%c",&_fract.intPart, &_razdel); //считываем разделитель после первой цифры: если нажат Enter, то число без дробной части, //если слеш, то только дробная часть, если пробел то и целая и дробная части присутствуют if (_razdel == '\n') { _fract.numerator = 0; _fract.denomerator = 1; } else if (_razdel == ' ') { //Считываем дробную часть scanf("%lld/%lld%*c", &_fract.numerator, &_fract.denomerator); if (_fract.denomerator == 0) _fract.denomerator = 1; } else if (_razdel == '/') { //Считываем знаменатель scanf("%lld%*c", &_fract.denomerator); if (_fract.denomerator == 0) _fract.denomerator = 1; _fract.numerator = _fract.intPart; _fract.intPart = 0; } //Сбрасываем входной поток fflush(stdin); return _fract; } Please help me! I think the problem with the input / output. post the code sorry for the Russian comments. INPUT //структура дроби struct Fractional { //объявление целой части, числителя и знаменателя long long intPart, numerator, denomerator; } _oneFract, _twoFract, _result; //функция считывания дроби Fractional ReadFractional() { Fractional _fract; //переменная _razdel определяет, что ввели: только целую часть, только дробную часть или целую и дробную часть char _razdel; //считываем первое число scanf("%lld",&_fract.intPart); //считываем разделитель после первой цифры: если нажат Enter, то число без дробной части, //если слеш, то только дробная часть, если пробел то и целая и дробная части присутствуют scanf("%c", &_razdel); if (_razdel == '\n') { _fract.numerator = 0; _fract.denomerator = 1; } else if (_razdel == ' ') { //Считываем дробную часть scanf("%lld/%lld", &_fract.numerator, &_fract.denomerator); if (_fract.denomerator == 0) _fract.denomerator = 1; } else if (_razdel == '/') { //Считываем знаменатель scanf("%lld", &_fract.denomerator); if (_fract.denomerator == 0) _fract.denomerator = 1; _fract.numerator = _fract.intPart; _fract.intPart = 0; } //Сбрасываем входной поток fflush(stdin); return _fract; } OUTPUT if (_result.intPart == 0) { if (_result.numerator == 0) { printf("0"); } else { printf("%lld/%lld", _result.numerator, _result.denomerator); } } else if (_result.numerator == 0) { printf("%lld",_result.intPart); } else { printf("%lld %lld/%lld",_result.intPart, _result.numerator, _result.denomerator); } The answers are checked and correct Edited by author 15.08.2012 17:22 After my wrong AC tests were added (Thanks to Fyodor Menshikov). Many authors lost AC.The problem was with division to negative divisors. (Example) 1/2 / -1/3 Good luck! I have WA #30, but on your test and on same tests my solution give right answers. Can be there others tricks? Try these tests: INPUT: 30000 29999/30000 * 30000 29999/30000 OUTPUT: 900059998 899940001/900000000 INPUT: 30000 29997/30000 / 1/29999 OUTPUT: 899999996 1/10000 Edited by author 05.05.2009 04:36 Thanks! You helped me a lot. Yes, I see. But I achieved the target - helped to the guys to find their bugs and get AC =) My program passed these tests, but it still has WA#29. (Before rejudge it has AC status). Does anybody have other hints or tests? OUCH! But on test 30000 29999/30000 * -30000 29999/30000 my prog outputs -20745377/900000000 instead of -900059998 899940001/900000000 hmm... thank you for good tests, Vedernikoff Sergey :) Now it's OK, just stupid mistake with labs function I saw with a help of this test. I don't know why it works wrong with long long numbers. I'll not use it anymore! Edited by author 06.03.2010 01:05 Edited by author 06.03.2010 01:06 thanks, first i WA#26 but when i see your test got AC, thanks, i dont forgot your help in all my life ;) sorry for my poor english. I'm veru happy!!! But anyone got AC fast? 0.015s and less memory I'm verY happy too... ;))) -5/7 + -5/7 ###### -1 3/7 0 / -1 25/31 ###### 0 1/7 * -49 7/9 ##### -7 1/9 -11 1/8 / -11 1/8 ##### 1 for test 1/7 * -49 7/9 ##### -7 1/9 answer -6 8/9 is rigth? In this compiler built-in abs() function casts its argument to int, so if you will pass long long there, it will not work. Take care of it and pass tests #29 and 30. If you have WA 29, use long long integer variable and if you haven't other bugs, you'll get AC :) Edited by author 16.07.2009 03:16 Who knows test data for test #11?? I got WA many times already on this test. Edited by author 21.06.2009 18:13 Aaaahh, mistaked in code))))) AC already. Hi..I had got my accepted solution rejudged and got WA#25. Then I corrected a mistake and now it is giving WA#29. Can somebody please give me a hint about test #29? I solved the problem some time ago, but recently I received a letter that my solution is rejudged. Now I got WA#30, but my program looks correct. Any ideas about test #30? New tests have been added. Accepted solutions have been rejudged. 295 authors have lost AC after rejudge. It is not so easy as it seems at first, but if you could separate all symbols and all numbers (I think this is the most difficult part of this task) - you'll get success! Some tests: IN: -2008/2009 - -2008/2009 OUT: 0 IN: 8/9 * 9/4 OUT: 2 IN: 7/10 / -10/7 OUT: -49/100 IN: 1 1/3 + 3 5/6 OUT: 5 1/6 My AC program gives 10/15 to the test 10/15 * 1 real answer is 2/3 |
|