Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1.  
  2. Problem Statement
  3.     
  4. Some rabbits are going to gather and hold a cake party. The exact number of rabbits participating in the party and the exact number of cakes prepared for the party are not determined yet. The rabbits say they want to divide the cakes in the following way. Let the number of rabbits be R and the number of cakes C. All C cakes are the same size. Each cake may be cut into two pieces (of possibly non-equal sizes) or kept uncut. Then the cakes and pieces of cake are distributed among the rabbits, so that all of the rabbits get the same amount of cake (that is, C/R cakes). You know that R is between minR and maxR, inclusive, and C is between minC and maxC, inclusive. Return the number of pairs (R, C) for which the division of cakes described above is possible.
  5. Definition
  6.     
  7. Class:
  8. RabbitsAndCakes
  9. Method:
  10. getNumber
  11. Parameters:
  12. int, int, int, int
  13. Returns:
  14. long
  15. Method signature:
  16. long getNumber(int minR, int maxR, int minC, int maxC)
  17. (be sure your method is public)
  18. Limits
  19.     
  20. Time limit (s):
  21. 2.000
  22. Memory limit (MB):
  23. 64
  24. Constraints
  25. -
  26. minR will be between 1 and 1,000,000, inclusive.
  27. -
  28. maxR will be between minR and 1,000,000, inclusive.
  29. -
  30. minC will be between 1 and 1,000,000, inclusive.
  31. -
  32. maxC will be between minC and 1,000,000, inclusive.
  33. Examples
  34. 0)
  35.  
  36.     
  37. 4
  38. 5
  39. 3
  40. 3
  41. Returns: 1
  42. For (R, C) = (4, 3) the division is possible. One possible way is as follows:
  43. Cut the first cake into two pieces: (a) of size 3/4 and (b) of size 1/4.
  44. Cut the second cake into two pieces: (c) of size 3/4 and (d) of size 1/4.
  45. Cut the third cake into two pieces: (e) of size 1/2 and (f) of size 1/2.
  46. Then:
  47. The first rabbit can take piece (a).
  48. The second rabbit can take pieces (b) and (e).
  49. The third rabbit can take piece (c).
  50. The fourth rabbit can take pieces (d) and (f).
  51. For (R, C) = (5, 3) the division is impossible.
  52. 1)
  53.  
  54.     
  55. 2
  56. 2
  57. 1
  58. 1000
  59. Returns: 1000
  60.  
  61. 2)
  62.  
  63.     
  64. 1
  65. 1000
  66. 2
  67. 2
  68. Returns: 4
  69.  
  70. 3)
  71.  
  72.     
  73. 4
  74. 7
  75. 4
  76. 7
  77. Returns: 14
  78.  
  79. 4)
  80.  
  81.     
  82. 64716
  83. 101247
  84. 99867
  85. 287365
  86. Returns: 6848769959
  87.  
  88. 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)2003, TopCoder, Inc. All rights reserved.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement