Statistics

Problem Statement for "EmoticonsDiv1"

Problem Statement

You are very happy because you advanced to the next round of a very important programming contest. You want your best friend to know how happy you are. Therefore, you are going to send him a lot of smile emoticons. You are given an int smiles: the exact number of emoticons you want to send.

You have already typed one emoticon into the chat. Then, you realized that typing is slow. Instead, you will produce the remaining emoticons using copy, paste, and possibly some deleting.

You can only do three different operations:
  1. Copy all the emoticons you currently have into the clipboard.
  2. Paste all emoticons from the clipboard.
  3. Delete one emoticon from the message.
Each operation takes precisely one second. Copying replaces the old content of the clipboard. Pasting does not empty the clipboard. You are not allowed to copy just a part of the emoticons you already have. You are not allowed to delete an emoticon from the clipboard.

Return the smallest number of seconds in which you can turn the one initial emoticon into smiles emoticons.

Definition

Class:
EmoticonsDiv1
Method:
printSmiles
Parameters:
int
Returns:
int
Method signature:
int printSmiles(int smiles)
(be sure your method is public)

Constraints

  • smiles will be between 2 and 1000, inclusive.

Examples

  1. 2

    Returns: 2

    First use copy, then use paste. The first operation copies one emoticon into the clipboard, the second operation pastes it into the message, so now you have two emoticons and you are done.

  2. 4

    Returns: 4

    One optimal solution is to copy the initial emoticon and then to paste it three times. Another optimal solution is to copy the one emoticon, paste it, copy the two emoticons you currently have, and paste two more.

  3. 6

    Returns: 5

    Copy. This puts one emoticon into the clipboard. Paste. You now have 2 emoticons in the message. Copy. The clipboard now contains 2 emoticons. Paste. You now have 4 emoticons in the message. Paste. You now have 6 emoticons in the message and you are done.

  4. 18

    Returns: 8

  5. 11

    Returns: 8

    Sometimes we actually do delete an emoticon in the optimal solution.

  6. 3

    Returns: 3

  7. 5

    Returns: 5

  8. 7

    Returns: 7

  9. 8

    Returns: 6

  10. 9

    Returns: 6

  11. 10

    Returns: 7

  12. 20

    Returns: 9

  13. 30

    Returns: 10

  14. 32

    Returns: 10

  15. 35

    Returns: 11

  16. 41

    Returns: 13

  17. 47

    Returns: 12

  18. 53

    Returns: 12

  19. 55

    Returns: 13

  20. 65

    Returns: 14

  21. 67

    Returns: 14

  22. 70

    Returns: 13

  23. 81

    Returns: 12

  24. 99

    Returns: 14

  25. 100

    Returns: 14

  26. 255

    Returns: 17

  27. 321

    Returns: 17

  28. 345

    Returns: 18

  29. 768

    Returns: 19

  30. 564

    Returns: 19

  31. 890

    Returns: 21

  32. 990

    Returns: 21

  33. 991

    Returns: 22

  34. 992

    Returns: 21

  35. 993

    Returns: 23

  36. 994

    Returns: 22

  37. 995

    Returns: 22

  38. 996

    Returns: 22

  39. 997

    Returns: 23

  40. 998

    Returns: 22

  41. 999

    Returns: 22

  42. 1000

    Returns: 21

  43. 977

    Returns: 24

  44. 901

    Returns: 24

  45. 961

    Returns: 22

  46. 508

    Returns: 19

  47. 959

    Returns: 21

  48. 968

    Returns: 20

  49. 22

    Returns: 10

  50. 512

    Returns: 18

  51. 123

    Returns: 16

  52. 513

    Returns: 19

  53. 817

    Returns: 23

  54. 729

    Returns: 18

  55. 111

    Returns: 16

  56. 833

    Returns: 22

  57. 847

    Returns: 21

  58. 33

    Returns: 11

  59. 509

    Returns: 20

  60. 34

    Returns: 11

  61. 506

    Returns: 20

  62. 124

    Returns: 15

  63. 501

    Returns: 20

  64. 510

    Returns: 19

  65. 26

    Returns: 10

  66. 127

    Returns: 15


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: