CCC '04 J2 - Terms of Office

View as PDF

Submit solution

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

Problem type
Canadian Computing Competition: 2004 Stage 1, Junior #2

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


  • -1
    stampixel  commented on May 2, 2022, 10:26 p.m.

    Ahh whats wrong with my code :(


    • 0
      rnpmat08  commented on Aug. 10, 2022, 9:37 a.m. edited

      I found your problem. For example, let's say X = 2000 and Y = 2124. Your output would output 2000 and 2060 correctly, but not after that since you're not updating the value of X anywhere. However, by changing the value of X, the for loop would be messed up due to X not being a constant and is present in the loop. I suggest you use a while loop instead.


  • -2
    JackCordingley  commented on March 26, 2022, 1:55 p.m.

    What is wrong with my code? https://dmoj.ca/src/4449409/raw


    • -3
      Spitfire720  commented on March 26, 2022, 7:27 p.m.

      You also need to account for year Y itself.


  • 0
    BaconBest  commented on May 17, 2021, 10:45 p.m.

    wait, does the start of the range is always all pos change?


    • -2
      Tempest_Enderman  commented on June 24, 2021, 10:27 p.m.

      Of course. It's written in the question. It says that since the new mayor just won the elect, he changed all of the positions


    • 4
      d  commented on May 18, 2021, 12:46 a.m.

      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.


  • -2
    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.


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

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


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

    This comment is hidden due to too much negative feedback. Show it anyway.


    • 4
      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.


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

        it worked bro tnx very much


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

    This comment is hidden due to too much negative feedback. Show it anyway.


    • 1
      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.


      • 5
        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...