The first problem uHunt suggested to me was 10055 Hashmat the brave warrior. It looks very easy, because all you have to do is subtract two numbers and get the absolute value of the difference. But ironically, it is very deceptive. I had several wrong answer submissions and I could not decipher what was wrong. It happens that this problem is a play on technicality. The problem states "The input numbers are not greater than 2^32." This probably means that plain integer data types won't be able to handle the integer storage. I used unsigned int, but I got wrong answer. Then I tried unsigned long int, still wrong. I also tried unsigned long long int, and still I got wrong answer. It was crazy and definitely a play on technicality. Then I checked the forums and noticed that I had to use %lld instead of %d in my sscanf() and printf() functions. It was a terrible experience because I felt that it was supposed to be a very easy problem. I ended up having more wrong answer submissions for this problem than probably any other problems in the past. And this problem was supposed to be one of the easier ones. Tsk, tsk.

Anyway, here's my code:

#include

int main() {

char line[100];

unsigned long long int a, b, c;

while (fgets(line, 100, stdin)) {

sscanf(line, "%lld %lld", &a, &b);

if (a > b) {

c = a - b;

}

else {

c = b - a;

}

printf("%lld\n", c);

}

return 0;

}

## No comments:

## Post a Comment