CCC '04 J2 - Terms of Office

View as PDF

Submit solution

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

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


  • 4
    possiblee  commented on Nov. 6, 2024, 2:25 a.m. edit 4

    Reminder on how to find the LCM (Least Common Multiple)

    First, find the prime factors of 2, 3, 4, 5

    2^1 (2, on a theoretical paper, cross this out) 3^1 (3) 2^2 (4) 5^1 (5)

    To find LCM, we need the highest power of each prime factor.

    In this case, the highest power of,

    2 is 2, between 2^1 and 2^2 3 is 1, between 3^1 and nothing 4 is 1, between 4^1 and nothing 5 is 1, between 5^1 and nothing

    Now to find LCM, 3^1 x 2^2 x 5^1 = 60

    Therefore the LCM of 2, 3, 4, 5, is 60 (I have no idea why the comment looks so different than what it's supposed to look like)


    • 0
      781159  commented on Dec. 1, 2024, 10:12 p.m.

      thank you, really helpful :))


  • -1
    IDKEthan  commented on Sept. 30, 2024, 4:23 p.m.

    Hello