## 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 2, 2022, 10:26 p.m.

Ahh whats wrong with my code :(

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

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

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

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

You also need to account for year Y itself.

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

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

• 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

• 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 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 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. Show it anyway.

• 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. Show it anyway.

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