## CCC '04 J2 - Terms of Office

View as PDF

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 , 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 and the future year and lists all years between and inclusive when all positions change.

#### Sample Input

2004
2100

#### Sample Output

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

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

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

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

This year, Year , 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.

• commented on March 19, 2020, 12:43 p.m.

What's wrong with my code?

• commented on March 19, 2020, 4:29 p.m.

You need to put brackets around the "i-x"s in your code. Right now, your program does not print anything at all.

• commented on Jan. 27, 2020, 12:57 a.m. edited

This comment is hidden due to too much negative feedback. Click here to view it.

• commented on Jan. 27, 2020, 6:40 p.m.

Don't spoil code for others who want to solve the problem. If you need help, consult the DMOJ slack

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

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

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

• commented on July 27, 2019, 7:26 p.m.

Use for loop

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

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

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

This comment is hidden due to too much negative feedback. Click here to view it.

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

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

it worked bro tnx very much

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

This comment is hidden due to too much negative feedback. Click here to view it.

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

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

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

This comment is hidden due to too much negative feedback. Click here to view it.

• 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 (i.e. includes first number, excludes last number), but the question wants the range (i.e. includes first number and last number).