Page 2 of 11

Posted: Mon Nov 12, 2007 11:41 am
by saman_saadi
but In my compiler I test below code and it was correct:

Code: Select all

	scanf("%d", &n);
	for (/*cin >> n*/; n--;)
	{
		cin.get();	//feeding new line character in scanf("%d", &n)
		ch1 = cin.get();
		ch2 = cin.get();
		cout << (unsigned char)ch1 << (unsigned char)ch2 << endl;
	}
or you can write:

Code: Select all

	scanf("%d\n", &n);
	for (/*cin >> n*/; n--;)
	{		
		ch1 = cin.get();
		ch2 = cin.get();
		cout << (unsigned char)ch1 << (unsigned char)ch2 << endl;
		cin.get(); //feeding new line character
	}

Posted: Mon Nov 12, 2007 11:52 am
by Lomir
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.

Posted: Mon Nov 12, 2007 12:19 pm
by Hojjat jafary

Code: Select all

like down

Posted: Mon Nov 12, 2007 12:20 pm
by hamedv
I got AC with this code

Code: Select all

like up!

Posted: Mon Nov 12, 2007 12:22 pm
by saman_saadi
Strange, now I check the range of characters and it was [-128, 127]. Is it possible they correct the input?

Posted: Mon Nov 12, 2007 12:25 pm
by hamedv
i got ac in contest and got ac after that

Posted: Mon Nov 12, 2007 12:45 pm
by Leonid
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 :)

Posted: Tue Nov 13, 2007 8:44 am
by RC's
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.

Posted: Tue Nov 13, 2007 9:11 am
by Darko
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.

Posted: Tue Nov 13, 2007 2:20 pm
by Lomir
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].

Posted: Tue Nov 13, 2007 2:50 pm
by saman_saadi
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!

Posted: Tue Nov 13, 2007 4:35 pm
by Lomir
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.

Posted: Tue Nov 13, 2007 11:01 pm
by sclo
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.

where's my wrong?

Posted: Wed Nov 14, 2007 6:44 am
by lovemagic

Code: Select all


....got AC

the scanf part with %c made the trouble....

Read Carefully

Posted: Wed Nov 14, 2007 7:04 am
by mohsincsedu
Before post anything u must read the previous posts carefully.... :wink: