ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1246. Tethered Dog

The coordinates are a pair of integers .... It's right ?
Posted by ryu 10 Jan 2009 23:18
I got AC after used double (instead long long).
Then I wrote code:

  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    P[i].x = ReadAndCheck();
    P[i].y = ReadAndCheck();
  }

double ReadAndCheck() {
  char s[100];
  scanf("%s", s);
  for (int i = 0; s[i]; ++i)
    Assert(isdigit(s[i]));
  double r;
  sscanf(s, "%lf", &r);
  return r;
}

To all appearences Assert was called (4 test).
Did you think about negative numbers?
Posted by Vladimir Yakovlev (USU) 11 Jan 2009 00:47
Re: The coordinates are a pair of integers .... It's right ?
Posted by Fyodor Menshikov 11 Jan 2009 15:04
I've got AC reading ints. Please change

Assert(isdigit(s[i]));
to
Assert(isdigit(s[i]) || s[i] == '-');

and test if Assert will be called.
Re: The coordinates are a pair of integers .... It's right ?
Posted by Fyodor Menshikov 11 Jan 2009 15:04
I've got AC reading ints. Please change

Assert(isdigit(s[i]));
to
Assert(isdigit(s[i]) || s[i] == '-');

and test if Assert will be called.