this is my code in the contest?
I'm aware of space char and the final value too.
and got the res in long long.
I'm completely confused...
- Code: Select all
woooooowh
what a great trick.
Got acc after that.
Thanks alot
Moderator: Board moderators
woooooowh
what a great trick.
Got acc after that.
Thanks alot
thanx all, got AC
rio wrote:Character code has range 0 ~ 255, so use unsigned char.
(Is the spoiler ?)
----
Rio
armansuleimenov wrote:I used stl map, got TLE, now switched to simple hash table, got WA 3 times. what is wrong with my code?
rio wrote:Finally figured out the trick after 20 few submissions..
Character code has range 0 ~ 255, so use unsigned char.
typedef basic_string<char> string;

so each element of string is char (not unsigned char) and you must handle this.
ll cost;
unsigned char ch;
cin>>ch>>cost;
cnt[(int)ch]=cost;
baodog wrote:Yes, you can read in char !! It just may be negative.
Simply add a constant !!! (128 or bigger)
Please, remove your code as good etiquette if you get ac.
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.
-128 <= x <= 127
0 <= x + 128 <= 255

armansuleimenov wrote:What input routine should I use then?
I can't use the code below since the character can be whitespace (' '):
unsigned char ch = cin.get();

scanf("%d\n",&m);
long total = 0;
while(m--){
unsigned char ch;
ch = cin.get();
cout << ch;
int cht = (int) ch;
}
darkos32 wrote:how to used cin.get() ?
i used like this for input :
2
av
sd
- Code: Select all
scanf("%d\n",&m);
long total = 0;
while(m--){
unsigned char ch;
ch = cin.get();
cout << ch;
int cht = (int) ch;
}
but it prints nothing..and how to check the newline ?
thanks.
int n, ch1, ch2;
for (cin >> n; n--;)
{
cin.get(); //feeding new line character in cin >> n
ch1 = cin.get();
ch2 = cin.get();
cout << (unsigned char)ch1 << (unsigned char)ch2 << endl;
}
ch = cin.get();
if (ch == '\n')
{
.
.
.
}
if (ch == '\n' || ch == '\r')

Users browsing this forum: No registered users and 1 guest