10055 - Hashmat the Brave Warrior
Moderator: Board moderators
10055
Although I have seen all the threads about 10055, I still cannot figure out the problem it is.
[pascal]
var
a,b:longint;
begin
while not eof do
begin
readln(a,b);
if a>b then writeln(a-b)
else writeln(b-a)
end
end.
[/pascal]
Can anyone slove my problem? Thanks.
[pascal]
var
a,b:longint;
begin
while not eof do
begin
readln(a,b);
if a>b then writeln(a-b)
else writeln(b-a)
end
end.
[/pascal]
Can anyone slove my problem? Thanks.
-
- Experienced poster
- Posts: 169
- Joined: Wed Oct 31, 2001 2:00 am
- Location: Singapore
Yeah Man AC!
I can solve that by using real!
Thanks For help!
Thanks For help!
Question
I tried the input 4294967296 0
and it returned 4294967296.
I tested with the GNU G++ and Dev C++ compiler and it worked fine.
However, I got WA...
[cpp]
// ACM Problem 10055
// Hashmat the brave warrior
// Done by Teh Ming Han
#include <iostream.h>
using namespace std;
int main(){
while (!cin.eof()){
unsigned long long int i=0,j=0,ch=0;
cin>>i>>j;
if (i>j)ch = i-j;
else ch=j-i;
cout<<ch<<endl;
}
return 0;
}[/cpp]
SO WHY DO I GET WRONG ANSWER?
and it returned 4294967296.
I tested with the GNU G++ and Dev C++ compiler and it worked fine.
However, I got WA...
[cpp]
// ACM Problem 10055
// Hashmat the brave warrior
// Done by Teh Ming Han
#include <iostream.h>
using namespace std;
int main(){
while (!cin.eof()){
unsigned long long int i=0,j=0,ch=0;
cin>>i>>j;
if (i>j)ch = i-j;
else ch=j-i;
cout<<ch<<endl;
}
return 0;
}[/cpp]
SO WHY DO I GET WRONG ANSWER?
:: HanWorks ::
10055 Time Limit Exceeded
Hi guys! I got a Time Limit Exceeded the last I posted this code for p10055. Any idea why it happened ???
[cpp]---CODE WAS CUT---[/cpp]
[cpp]---CODE WAS CUT---[/cpp]
Last edited by raysa on Wed Apr 09, 2003 8:56 am, edited 3 times in total.
-
- Guru
- Posts: 834
- Joined: Wed May 29, 2002 4:11 pm
- Location: Wroclaw, Poland
- Contact:
try
instead of
Best regards
Dominik
Code: Select all
while(scanf("%ld %ld",&a,&b) != 2)
Code: Select all
while(scanf("%ld %ld",&a,&b) != EOF)
Dominik
-
- Guru
- Posts: 647
- Joined: Wed Jun 26, 2002 10:12 pm
- Location: Hong Kong and New York City
- Contact:
I think Dominik means this:
Code: Select all
while(scanf("%ld %ld",&a,&b) == 2)