Statistics

Problem Statement for "SettingTents"

Problem Statement

Once upon a time, there lived a migrant barbarian tribe. Every time it settled down, a tent was set for the chief of the tribe. First, an area was selected and divided into NxM squares with side lengths of 1 unit. Then, they chose a site for the tent in such a way that every vertex of its base coincided with some vertex of one of the squares. According to an ancient tradition, the base had to be a rhomb. For example, there are all 6 different possible sites for the tent in a 2x2 area:


       

       

An example of a tent in a 4x2 area:
   

For a given N and M, return the number of different possible sites for the chief's tent. Two sites are different if there is at least one vertex which belongs to one site but not the other.

Definition

Class:
SettingTents
Method:
countSites
Parameters:
int, int
Returns:
int
Method signature:
int countSites(int N, int M)
(be sure your method is public)

Notes

  • A rhomb is a four-sided polygon with sides of equal length.
  • The tent must have non-zero area.

Constraints

  • N will be between 1 and 100, inclusive.
  • M will be between 1 and 100, inclusive.

Examples

  1. 2

    2

    Returns: 6

    The example from the problem statement.

  2. 1

    6

    Returns: 6

    The only possible sites are the squares of the area themselves.

  3. 6

    8

    Returns: 527

  4. 100

    100

    Returns: 38235298

  5. 98

    99

    Returns: 35869694

  6. 1

    1

    Returns: 1

  7. 26

    1

    Returns: 26

  8. 100

    1

    Returns: 100

  9. 1

    100

    Returns: 100

  10. 1

    56

    Returns: 56

  11. 2

    27

    Returns: 262

  12. 66

    2

    Returns: 1286

  13. 3

    3

    Returns: 22

  14. 9

    3

    Returns: 120

  15. 3

    88

    Returns: 4900

  16. 4

    100

    Returns: 12716

  17. 25

    25

    Returns: 111977

  18. 44

    46

    Returns: 1324538

  19. 50

    50

    Returns: 2068014

  20. 31

    74

    Returns: 1362536

  21. 31

    75

    Returns: 1393342

  22. 31

    76

    Returns: 1424388

  23. 31

    77

    Returns: 1455562

  24. 77

    78

    Returns: 13083584

  25. 77

    79

    Returns: 13433601

  26. 77

    80

    Returns: 13790536

  27. 81

    84

    Returns: 17003180

  28. 91

    90

    Returns: 25121322

  29. 91

    91

    Returns: 25714110

  30. 91

    92

    Returns: 26312048

  31. 91

    93

    Returns: 26912486

  32. 100

    90

    Returns: 30481429

  33. 66

    33

    Returns: 1316270

  34. 11

    97

    Returns: 138062

  35. 37

    81

    Returns: 2489211

  36. 99

    100

    Returns: 37429856

  37. 100

    99

    Returns: 37429856

  38. 61

    17

    Returns: 209747

  39. 32

    64

    Returns: 1155462

  40. 64

    88

    Returns: 10973510

  41. 81

    27

    Returns: 1107492

  42. 20

    20

    Returns: 43850

  43. 21

    29

    Returns: 101297

  44. 48

    98

    Returns: 6621616

  45. 45

    35

    Returns: 760000

  46. 40

    31

    Returns: 458936

  47. 83

    28

    Returns: 1267800

  48. 45

    69

    Returns: 3043939

  49. 26

    64

    Returns: 683457

  50. 52

    70

    Returns: 4399078

  51. 49

    44

    Returns: 1505592

  52. 73

    26

    Returns: 848910

  53. 59

    89

    Returns: 9247310

  54. 2

    7

    Returns: 32

  55. 20

    71

    Returns: 409116

  56. 31

    70

    Returns: 1241480

  57. 91

    26

    Returns: 1210502

  58. 71

    78

    Returns: 10985040

  59. 3

    18

    Returns: 350

  60. 68

    30

    Returns: 1089123

  61. 56

    17

    Returns: 183052

  62. 5

    65

    Returns: 9891

  63. 65

    74

    Returns: 8137442

  64. 100

    21

    Returns: 798880

  65. 71

    79

    Returns: 11268888

  66. 18

    44

    Returns: 143459

  67. 52

    68

    Returns: 4163986

  68. 32

    33

    Returns: 336720

  69. 19

    15

    Returns: 20940

  70. 38

    16

    Returns: 83288

  71. 86

    75

    Returns: 15076350

  72. 22

    2

    Returns: 186

  73. 82

    79

    Returns: 15331400

  74. 99

    89

    Returns: 29142341

  75. 97

    99

    Returns: 35099673

  76. 100

    98

    Returns: 36634311

  77. 99

    99

    Returns: 36645046

  78. 98

    67

    Returns: 14932418


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: