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

Show all messages Hide all messages

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? Vladimir Yakovlev (USU) 11 Jan 2009 00:47
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.
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.