10055 - Hashmat the Brave Warrior

All about problems in Volume 100. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
Shahid
Learning poster
Posts: 68
Joined: Fri Oct 26, 2001 2:00 am
Location: Dhaka, Bangladesh
Contact:

10055 - Hashmat the Brave Warrior

Post by Shahid » Fri May 03, 2002 3:22 pm

whats the maximum input?

i.e. i want to know if the number 4294967296(2^32) can be given as any of the input?

in c++, the highest unsigned long range is i found 4294967295, so this is important to know....plz help

Stefan Pochmann
A great helper
Posts: 284
Joined: Thu Feb 28, 2002 2:00 am
Location: Germany
Contact:

Post by Stefan Pochmann » Sat May 04, 2002 12:37 am

Read the problem description. It says: "The input numbers are not greater than 2^32." That should answer your question.

Shahid
Learning poster
Posts: 68
Joined: Fri Oct 26, 2001 2:00 am
Location: Dhaka, Bangladesh
Contact:

Post by Shahid » Sun May 05, 2002 3:00 am

i make a solution for the highest (2^32) number and it shows right answers. it needs a special treatment cauze it is outside the range of unsigned long in c/c++......
without this i think this a subtraction problem.....

but still i get wrong answer....so is there any other holes that is hidden in the problem?

Stefan Pochmann
A great helper
Posts: 284
Joined: Thu Feb 28, 2002 2:00 am
Location: Germany
Contact:

Post by Stefan Pochmann » Sun May 05, 2002 3:07 am

Read the problem description veeery carefully. There's a part that says "vice versa" or sth like that.

User avatar
Ming Han
Learning poster
Posts: 77
Joined: Thu Jun 06, 2002 7:10 pm
Location: Singapore
Contact:

Wrong Answer

Post by Ming Han » Sun Jun 16, 2002 6:43 pm

My code as follows:
[cpp]
// ACM Problem 10055
// Hashmat the brave warrior
// Done by Teh Ming Han

#include <stdio.h>

int main(){
unsigned long i=0,j=0,ch=0;
while (scanf("%d %d",&i,&j)==2){
if (i>j)ch = i-j;
else ch=j-i;
printf("%d\n",ch);
}
return 0;
}[/cpp]

What i don't understand is why I get wrong answer.

10153EN
Experienced poster
Posts: 148
Joined: Sun Jan 06, 2002 2:00 am
Location: Hong Kong
Contact:

Post by 10153EN » Sun Jun 16, 2002 6:49 pm

Try this
4294967296 0

Caesum
Experienced poster
Posts: 225
Joined: Fri May 03, 2002 12:14 am
Location: UK
Contact:

Post by Caesum » Sun Jun 16, 2002 6:50 pm

read the first two posts and that should answer your problem

User avatar
Ming Han
Learning poster
Posts: 77
Joined: Thu Jun 06, 2002 7:10 pm
Location: Singapore
Contact:

Thanks

Post by Ming Han » Sun Jun 16, 2002 7:00 pm

Thanks a lot

Vartanov Daniel
New poster
Posts: 5
Joined: Tue Aug 27, 2002 7:46 pm
Location: Russia
Contact:

10055 - Hashmat the brave warrior; What's the trick here?

Post by Vartanov Daniel » Wed Aug 28, 2002 11:02 am

I really didn't understand, how to get WA for this problem, and i understood it after i posted my solution. Is there some tricks in this problem?

Code: Select all

#include <stdio.h>

int main()
{
  unsigned long hashmat, versa;
  while (scanf("%ld %ld", &hashmat, &versa) == 2)
    printf("%ld\n", versa - hashmat);
  return 0;
}
[/cpp]

Adrian Kuegel
Guru
Posts: 724
Joined: Wed Dec 19, 2001 2:00 am
Location: Germany

Post by Adrian Kuegel » Wed Aug 28, 2002 11:18 am

This problem has already a thread where your question is answered. Why it is so difficult to use something like "find in page" and insert the problem number?

karl
New poster
Posts: 11
Joined: Tue Jul 16, 2002 1:03 pm

Post by karl » Wed Aug 28, 2002 3:49 pm

Adrian, we are a little bit lazy, aren't we? :wink:

But before scanning hundreds of postings, I'll try to help!!!


Given input a, b, it isn't said, that a<b in every case.
Try input and you'll find something very interesting...
12 10

Read problem description very carefully, second sentence of the "Input" section!

Hope, this helps.

Vartanov Daniel
New poster
Posts: 5
Joined: Tue Aug 27, 2002 7:46 pm
Location: Russia
Contact:

Post by Vartanov Daniel » Wed Aug 28, 2002 8:00 pm

Thanks a lot... it was my fault, may be because of bad English :))))

saugata bose
New poster
Posts: 3
Joined: Wed Aug 21, 2002 12:49 pm
Location: bangladesh

hared in easyyyyyyyyyyyyyyyy???

Post by saugata bose » Thu Aug 29, 2002 9:34 am

it returns value vice versa
1st value may be small or greater


saugata
saugata

arnsfelt
New poster
Posts: 44
Joined: Wed Oct 17, 2001 2:00 am
Location: Denmark
Contact:

Post by arnsfelt » Thu Sep 05, 2002 11:20 am

The input numbers are not greater than 2^32

Joana Lopes
New poster
Posts: 1
Joined: Sat Sep 28, 2002 4:48 pm
Contact:

10055 - i can't find a problem here

Post by Joana Lopes » Sat Sep 28, 2002 4:51 pm

:oops:
Well i've read carefully the problem and i'm still receiving a wrong answer.
I know i't a very simple problem maybe i'm becoming blind..
int main()
{
int army1,army2;
while(scanf("%d %d",&army1, &army2)!=EOF)
{
if (army2>=army1)
{
printf("%d\n",(army2-army1));
}
else
printf("%d\n",(army1-army2));
}

return 0;
}

please answer me.
Thanks

Post Reply

Return to “Volume 100 (10000-10099)”