CCC '04 J2 - Terms of Office

View as PDF

Submit solution


Points: 3
Time limit: 2.0s
Memory limit: 64M

Problem type

2004 Canadian Computing Competition, Stage 1

In CS City, a mathematical place to live, the mayor is elected every 4 years, the treasurer is appointed every 2 years, the chief programmer is elected every 3 years and the dog-catcher is replaced every 5 years.

This year, Year X, the newly elected mayor announced the appointment of the new treasurer, a new dog-catcher and congratulated the chief programmer for winning the recent election. That is, all positions were changed over. This is highly unusual. You will quantify how unusual this really is.

Write a program that inputs the year X and the future year Y and lists all years between X and Y inclusive when all positions change.

Sample Input

2004
2100

Sample Output

All positions change in year 2004
All positions change in year 2064

Comments


  • 0
    jfu0952  commented on Aug. 8, 2018, 11:18 p.m.

    UGH


  • 0
    AlexTu  commented on April 1, 2018, 7:20 p.m. edited

    Don't know what's wrong with my solution :/ Edit: Got it


  • 0
    Dordor1218  commented on Feb. 1, 2018, 7:18 p.m. edit 2

    What's wrong with my code? I tried different cases on my computer and their all correct.


    • 0
      Injust  commented on Feb. 1, 2018, 8:21 p.m.

      Re-read the sample output. Outputting just the year is not correct.


  • -5
    mrglioula  commented on Dec. 20, 2017, 3:19 p.m.

    what is wrong here!!!!!


    • 0
      ZippIE  commented on Dec. 20, 2017, 3:31 p.m.

      all years between X and Y inclusive

      Your solution only checks up to year Y - 1.


      • -3
        mrglioula  commented on Dec. 20, 2017, 3:37 p.m.

        it worked bro tnx very much


  • 0
    Mxtute  commented on Dec. 6, 2017, 11:58 a.m. edit 7

    Having  trouble.


    • 0
      Roynaruto  commented on Dec. 6, 2017, 12:27 p.m.

      The mayor every 4, the treasurer every 2, the chief programmer every 3, and the dog-catcher every 5 years. How many years does it take for all of them to change at the same time? Think very carefully.


      • 0
        Laurak121  commented on Aug. 12, 2018, 7:03 a.m.

        First get their LCM which is 60 you might think its thirty... but is it a multiple of four? lol 4, 8, 12, 16, 20, 24, 28, 32... 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30 ... 3, 6, 9, 12, 15, 18, 21, 24, 27, 30... 5, 10, 15, 20, 25, 30...


  • -6
    MateiG  commented on July 4, 2017, 5:23 a.m.

    It says IR, and then WA, but every input that I've tried works. Are you sure that your inputs are correct in terms of what the question specifies?!


    • 7
      Kirito  commented on July 4, 2017, 11:02 a.m.

      Consider that over 400 users have solved the problem. Is it more likely that there is an error in the input, or an error in your program?

      Hint: Python's range(X, Y) generates the range [X, Y) (i.e. includes first number, excludes last number), but the question wants the range [X, Y] (i.e. includes first number and last number).