10055 - Hashmat the Brave Warrior
Moderator: Board moderators
-
- Learning poster
- Posts: 68
- Joined: Fri Oct 26, 2001 2:00 am
- Location: Dhaka, Bangladesh
- 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
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
-
- A great helper
- Posts: 284
- Joined: Thu Feb 28, 2002 2:00 am
- Location: Germany
- Contact:
-
- Learning poster
- Posts: 68
- Joined: Fri Oct 26, 2001 2:00 am
- Location: Dhaka, Bangladesh
- 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?
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?
-
- A great helper
- Posts: 284
- Joined: Thu Feb 28, 2002 2:00 am
- Location: Germany
- Contact:
Wrong Answer
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.
[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.
Thanks
Thanks a lot
-
- 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?
[/cpp]
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;
}
-
- Guru
- Posts: 724
- Joined: Wed Dec 19, 2001 2:00 am
- Location: Germany
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.

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.
-
- New poster
- Posts: 5
- Joined: Tue Aug 27, 2002 7:46 pm
- Location: Russia
- Contact:
-
- New poster
- Posts: 3
- Joined: Wed Aug 21, 2002 12:49 pm
- Location: bangladesh
hared in easyyyyyyyyyyyyyyyy???
it returns value vice versa
1st value may be small or greater
saugata
1st value may be small or greater
saugata
saugata
-
- 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;
}
please answer me.
Thanks