## 10055 - Hashmat the Brave Warrior

Moderator: Board moderators

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

### 10055 - Hashmat the Brave Warrior

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:
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
Contact:
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:
Read the problem description veeery carefully. There's a part that says "vice versa" or sth like that.

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

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:
Try this
4294967296 0

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

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

### Thanks

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?

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]

Guru
Posts: 724
Joined: Wed Dec 19, 2001 2:00 am
Location: Germany
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
Adrian, we are a little bit lazy, aren't we?

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:
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

### hared in easyyyyyyyyyyyyyyyy???

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:
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

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;
}