char ch = 255;
ch is negative one !
but the clarification said that the character codes are non-negative.
"character value" In clarification means the amount of money paid for character. There is nothing said about character code. So codes may be in range of 0-225, and you must use usigned version of char.
Btw, there is no spaces, \t or \n as paid characters.
Solution for each test case must be printed on a separate line.
I.e.
Code:
10.10$
10.11$
Each character value is non-negative and at most 1000 cents worth.
That was ment to say, that character value IN CENTS is non-negative, but not character code . Although character code is non-negative too (refer the following table: http://www.asciitable.com/). But since you read it in "char", which has range -128 <= x < 128 then every character in input which has code greater or equal than 128 is converted to negative value and you get WA
I used char but I get AC..
I think the problem is not because of that.
In the past I got WA because I use int for the cost, after I use unsigned long long to store the value before dividing it by 100, I got AC.
Where did the input come from? Are you sure that the character values are in [0..255]?
The reason I am asking is because I had to increase the array sizes to get it to pass in Java. If the text was copied and pasted from somewhere, it probably contained Unicode characters.
Yes, test input was copied. However it was resaved in ANSI encoding. So, I think that no characters higher then 255 have left.
I use gets() and vector of 255 elements.
If there was some unicode characters I think you sould get WA. Because my solution work only with char/usigned char [0..255].
RC's wrote:I used char but I get AC..
I think the problem is not because of that.
In the past I got WA because I use int for the cost, after I use unsigned long long to store the value before dividing it by 100, I got AC.
I use char and got WA then I change char to unsigned char and got AC. One of my friends got AC using char. It's interesting that he use int for the cost not unsigned long long!
int for total cost is enought. We are not so cruel
Maximum answer is: 1766189.55$.
Maybe you used C not C++? I do not know how it works in C.
As far as C++ unsinged char must be used. Overway you will index array out of boundary and this is UB.
I used C and char and got WA. I think the problem is that I should've gotten run-time error, but the judge did not catch it and gave WA instead. I used more than 10 submissions on this problem.