Statistics

Problem Statement for "CalendarRecycle"

Problem Statement

Jane is visiting your cubicle when she spies the Elvis calendar hanging on your wall.

"That's not right, is it?" she asks rhetorically.

Your Elvis calendar says that September 8 is a Sunday, but it's actually a Monday. Elvis Presley, the King of Rock 'n' Roll, is no liar. It's just that you bought the calendar last year. This is a 2002 calendar, whereas the current year is 2003. The dates no longer match the days of the week! But there will come a year when every date falls on the same day of the week as in 2002, and the King will reign again.

Given an int representing a year between 2002 and 9999, return the closest future year with which it shares a calendar. Jane reminds you that there are 30 days in April, June, September, and November. The remaining months, with the exception of February, have 31 days. February has 29 days in leap years, and 28 days otherwise. Leap years are divisible by four, and not divisible by 100 unless they are also divisible by 400. For example, 2004 and 2400 are leap years, but 2003 and 2100 are not. Jane also points out that there are only 14 possible calendars.

Definition

Class:
CalendarRecycle
Method:
useAgain
Parameters:
int
Returns:
int
Method signature:
int useAgain(int year)
(be sure your method is public)

Constraints

  • year is between 2002 and 9999, inclusive

Examples

  1. 2002

    Returns: 2013

    Your 2002 Elvis calendar will be valid again in 2013. The following table shows the day of the week that September 8th falls on each year from 2002 to 2013. Year | Day -----+----- 2002 | Sunday 2003 | Monday 2004 | Wednesday 2005 | Thursday 2006 | Friday 2007 | Saturday 2008 | Monday 2009 | Tuesday 2010 | Wednesday 2011 | Thursday 2012 | Saturday 2013 | Sunday

  2. 2013

    Returns: 2019

    After 2013, your 2002 Elvis calendar will next be valid in 2019.

  3. 2008

    Returns: 2036

  4. 9999

    Returns: 10010

  5. 2525

    Returns: 2531

  6. 5442

    Returns: 5453

  7. 7243

    Returns: 7254

  8. 2372

    Returns: 2400

  9. 2938

    Returns: 2949

  10. 5873

    Returns: 5879

  11. 2937

    Returns: 2943

  12. 9501

    Returns: 9507

  13. 3326

    Returns: 3337

  14. 9706

    Returns: 9717

  15. 2177

    Returns: 2183

  16. 7848

    Returns: 7876

  17. 2959

    Returns: 2970

  18. 6576

    Returns: 6616

  19. 9408

    Returns: 9436

  20. 6965

    Returns: 6971

  21. 4094

    Returns: 4100

  22. 7617

    Returns: 7623

  23. 9288

    Returns: 9328

  24. 9378

    Returns: 9389

  25. 3584

    Returns: 3612

  26. 3834

    Returns: 3845

  27. 5139

    Returns: 5150

  28. 3305

    Returns: 3311

  29. 6941

    Returns: 6947

  30. 7596

    Returns: 7624

  31. 7435

    Returns: 7446

  32. 3861

    Returns: 3867

  33. 6732

    Returns: 6760

  34. 9352

    Returns: 9380

  35. 5332

    Returns: 5360

  36. 4675

    Returns: 4686

  37. 6750

    Returns: 6761

  38. 3276

    Returns: 3316

  39. 9770

    Returns: 9781

  40. 5709

    Returns: 5715

  41. 5663

    Returns: 5674

  42. 5375

    Returns: 5386

  43. 9626

    Returns: 9637

  44. 6108

    Returns: 6136

  45. 3102

    Returns: 3113

  46. 3375

    Returns: 3386

  47. 8453

    Returns: 8459

  48. 9852

    Returns: 9880

  49. 9286

    Returns: 9297

  50. 5279

    Returns: 5290

  51. 3288

    Returns: 3328

  52. 4561

    Returns: 4567

  53. 5403

    Returns: 5414

  54. 6053

    Returns: 6059

  55. 7574

    Returns: 7585

  56. 9692

    Returns: 9704

  57. 6324

    Returns: 6352

  58. 2155

    Returns: 2166

  59. 3646

    Returns: 3657

  60. 3764

    Returns: 3792

  61. 7987

    Returns: 7998

  62. 5962

    Returns: 5973

  63. 5802

    Returns: 5813

  64. 8275

    Returns: 8286

  65. 5089

    Returns: 5095

  66. 5170

    Returns: 5181

  67. 6273

    Returns: 6279

  68. 5954

    Returns: 5965

  69. 3892

    Returns: 3904

  70. 8011

    Returns: 8022

  71. 3576

    Returns: 3604

  72. 9766

    Returns: 9777

  73. 5495

    Returns: 5501

  74. 2537

    Returns: 2543

  75. 9657

    Returns: 9663

  76. 8449

    Returns: 8455

  77. 3949

    Returns: 3955

  78. 4134

    Returns: 4145

  79. 4407

    Returns: 4418

  80. 2981

    Returns: 2987

  81. 3250

    Returns: 3261

  82. 8222

    Returns: 8233

  83. 3482

    Returns: 3493

  84. 9455

    Returns: 9466

  85. 6591

    Returns: 6603

  86. 6963

    Returns: 6974

  87. 6130

    Returns: 6141

  88. 6533

    Returns: 6539

  89. 9446

    Returns: 9457

  90. 7762

    Returns: 7773

  91. 8597

    Returns: 8609

  92. 4990

    Returns: 5002

  93. 4718

    Returns: 4729

  94. 5260

    Returns: 5288

  95. 4534

    Returns: 4545

  96. 6528

    Returns: 6556

  97. 8062

    Returns: 8073

  98. 7667

    Returns: 7678

  99. 8224

    Returns: 8252

  100. 7266

    Returns: 7277

  101. 2008

    Returns: 2036

  102. 9999

    Returns: 10010

  103. 2300

    Returns: 2306

  104. 2100

    Returns: 2106

  105. 9996

    Returns: 10024

  106. 2099

    Returns: 2105

  107. 2072

    Returns: 2112

  108. 2400

    Returns: 2428

  109. 9900

    Returns: 9906

  110. 9992

    Returns: 10020


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: