Statistics

Problem Statement for "TheRoundCityDiv2"

Problem Statement

John and Brus have found a nice horizontal plane and they built a round city somewhere on the plane. The center of the city is at coordinates (0, 0). This point is left empty. There is a house at each other lattice point that is at most r units away from the city center. That is, the lattice point (x, y) other than (0, 0) contains a house if and only if sqrt(x*x + y*y) ≤ r.

John and Brus now want to count all houses in the city. You are given the int r. Return the number of houses.

Definition

Class:
TheRoundCityDiv2
Method:
find
Parameters:
int
Returns:
int
Method signature:
int find(int r)
(be sure your method is public)

Constraints

  • r will be between 1 and 100, inclusive.

Examples

  1. 1

    Returns: 4

    There are four houses in the city: (0, 1), (0, -1), (1, 0) and (-1, 0).

  2. 2

    Returns: 12

    There are twelve houses in the city: (0, 1), (0, -1), (1, 0), (-1, 0), (0, 2), (0, -2), (2, 0), (-2, 0), (1, 1), (1, -1), (-1, 1) and (-1, -1).

  3. 3

    Returns: 28

    There are twenty-eight houses in the city: (0, 1), (0, -1), (1, 0), (-1, 0), (0, 2), (0, -2), (2, 0), (-2, 0), (1, 1), (1, -1), (-1, 1), (-1, -1), (0, 3), (0, -3), (3, 0), (-3, 0), (1, 2), (1, -2), (-1, 2), (-1, -2), (2, 1), (2, -1), (-2, 1), (-2, -1), (2, 2), (2, -2), (-2, 2) and (-2, -2).

  4. 47

    Returns: 6920

  5. 96

    Returns: 28916

  6. 75

    Returns: 17664

  7. 86

    Returns: 23216

  8. 85

    Returns: 22700

  9. 17

    Returns: 900

  10. 23

    Returns: 1652

  11. 52

    Returns: 8496

  12. 83

    Returns: 21628

  13. 64

    Returns: 12852

  14. 88

    Returns: 24312

  15. 62

    Returns: 12060

  16. 78

    Returns: 19108

  17. 97

    Returns: 29524

  18. 56

    Returns: 9844

  19. 65

    Returns: 13272

  20. 31

    Returns: 3000

  21. 99

    Returns: 30756

  22. 92

    Returns: 26564

  23. 57

    Returns: 10188

  24. 30

    Returns: 2820

  25. 96

    Returns: 28916

  26. 69

    Returns: 14948

  27. 76

    Returns: 18124

  28. 2

    Returns: 12

  29. 14

    Returns: 612

  30. 43

    Returns: 5788

  31. 31

    Returns: 3000

  32. 45

    Returns: 6360

  33. 37

    Returns: 4292

  34. 60

    Returns: 11288

  35. 33

    Returns: 3408

  36. 73

    Returns: 16728

  37. 67

    Returns: 14072

  38. 59

    Returns: 10912

  39. 94

    Returns: 27728

  40. 78

    Returns: 19108

  41. 70

    Returns: 15372

  42. 45

    Returns: 6360

  43. 70

    Returns: 15372

  44. 30

    Returns: 2820

  45. 47

    Returns: 6920

  46. 70

    Returns: 15372

  47. 100

    Returns: 31416


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: