Project Euler Problem 19
20世紀中に月の初めが日曜日になるのは何回あるか?
次の情報が与えられている.- 1900年1月1日は月曜日である.
- 9月, 4月, 6月, 11月は30日まであり, 2月を除く他の月は31日まである.
- 2月は28日まであるが, うるう年のときは29日である.
- うるう年は西暦が4で割り切れる年に起こる. しかし, 西暦が400で割り切れず100で割り切れる年はうるう年でない.
20世紀(1901年1月1日から2000年12月31日)中に月の初めが日曜日になるのは何回あるか?
Counting Sundays
You are given the following information, but you may prefer to do some research for yourself.・ 1 Jan 1900 was a Monday.
・ Thirty days has September,
April, June and November.
All the rest have thirty-one,
Saving February alone,
Which has twenty-eight, rain or shine.
And on leap years, twenty-nine.
・ A leap year occurs on any year evenly divisible by 4, but not on a century unless it is divisible by 400.
How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)?
考え方
曜日の計算に、「ツェラーの公式」というものがある。こちらのページを参考にさせていただいた。→ http://www.kkaneko.com/adp/ad/date.html