|
|
I think it sholud be said in statement that we do rounding to near number. I spent 20 minutes, understanding why my code doesn't work for sample test, but the mistake was here: floor(100*x)/100, because I thought we should round to bottom You can just do calculations with floats as much as possible, e.g., 15% = 0.15, binary search with epsilon = 0.0001. Rounding with round(x, 2) are needed only when: 1. K*L 2. output of T(K) -- "The calculation of the regional coefficient and all kinds the taxes is made with rounding off to two digits after a decimal point." while K itself is float. A test like this is possible: 15 0 35 12000000 12000000 -1 First time it occurs in Test 9. This means that you should pay the same tax for any amount of salary. It is ok to output 0.00 for all such tests, despite it is not correct always because of interim roundings of regional coefficient. Everything else is well-described in previous comments, basically correct numbers round and correct searching of initial salary (you should search for max possible value with 2 decimal places in it) are the only things that can make the initial problem description being unclear. Vasilenko Oleg (South Ural State University) WA 7 // Problem 1300. Taxes 7 Apr 2010 20:48 I apply rounding (as floor(x*100+0.5)/100) only to RESULT of T(R) and to regional coefficient. But I can't pass test 7. Can anybody help me? In this problem we need to calculate R(S): F(R) = S, where F(R) = R – T(R) + L%*R – T(L%*R). But function F(R) is NOT increase monotonically! In other words, it is possible to find R: F(R) = F(R+1). So, it is impossible to calculate unique R(S). Example: 99 1000000000 10 2000000000 40 3000000000 41 0 77 100000000 2000000000 3000000000 4200000000 5000000000 1100000001 2200000000 3300000001 -1 If in your program R(S) = max{R: F(R) = S} then answer = 11086345330.78 (and you'll get AC) If in your program R(S) = min{R: F(R) = S} then answer = 11086345330.81 (and you'll get WA #7) Also your program can write another answers. Which of they are correct? And why? Admins. I think Walrus is right. may be need to change a statement... It is mathematical situation and not of statement. max{R: F(R) = S} may be =1/3 and approxed by double with eps. After rounding this eps may convert 0.4999999999~0.0 in 0.5000000000001~1. Thus we must solve the problem above fractions __int64/_int64. Got Ac when R is double but after floor(R*100+0.5)/100 This problem is another example that in double calculations we need in description of the author algorithm. Edited by author 26.08.2009 12:56 There is no fractions. I just used int64. :) Suggestion to find R(S) = max{R: F(R) = S} must be added with information: In what class of numbers should we seach of the S? 1) Numbers of pattern ########.## - rubles and copeys 2) All real numbers i can't understand, why, where, and how I must round intermediate results. I try it all, but got WA on test 1..3 please help me!!! or you can send me AC program, that i may understand this condition. my e-mail: twoalias [Alfa] inbox.ru Please, throw the decision these are problems on e-mail: ufo.nix@mail.ru Would make itself, but now a blockage on study... I am not in time..:-( What is it? I first got it. And what do with it? If you whant I can give you my code mailto: tolik-tol@inbox.ru The algo is easy, but you must read the problem's description very carefully, and take care of rounding: r = int(r * 100 + 0.5) / 100, use it when calc tax and add up... Because of rounding, it takes me almost one day to AC this problem...:( Samun_Victor [SESC USU] WA2 [1] // Problem 1300. Taxes 5 Jun 2005 11:50 my source: (Pascal) begin end. I need get WA1, but I get WA2. What is it? A bug? My program always wrong, but I don't know why, if you got AC, can you send me your program? I do not understand how the rounding occurs. First of all is it a floor(x*100)/100 (trunc-like) or a floor(x*100+0.5)/100 (round-like)? When does it occur? At any operation other than addition? For example, when computing the taxes for some value, the result is rounded at every segment (where percentage is applied) or only after the summation? When computing T(R*L%), R*L% is rounded before computations or not? The gross profit for each enterprise (the one we have to compute) is also with only 2 decimals? Rounding is floor(x*100+0.5)/100 It applies to result of T(K) and to regional coefficient. I guess it is obvious that the sample and some of the test are COMPLETELY WRONG. Does anybody have an idea where does the sample answer come from? Any ideas that you'd like to share? I promise it is obvious that the sample and all of the test are COMPLETELY RIGHT . Maybe you misunderstood it . Notice that the money got from the companies is the "net profit", in other words,it's R-T(R)+R*L%-T(R*L%).So you should calculate R first according to the rules. |
|
|