ProjectEuler 364 Comfortable distance - 拼圖
By Kyle
at 2011-12-25T00:08
at 2011-12-25T00:08
Table of Contents
364. Comfortable distance
http://projecteuler.net/problem=364
有 N 個座位排成一排,N 個人依序入座並把座位坐滿,但是入座條件如下:
1. 當有某座位的左右兩個相鄰的座位都沒人時,他就坐這裡。
2. 當已經沒有上述條件的座位時,就退而求其次,挑有一邊沒有坐人的座位坐下。
3. 當已經沒有上述條件的座位時,就挑剩下的座位坐。
使 T(N) 表示為有 N 個人要用上述條件去坐滿 N 個座位時的方法數
下列圖示表示出 T(4) = 8
┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐
│●│ │ │ │→│●│ │●│ │→│●│ │●│●│→│●│●│●│●│
└─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘
┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐
│●│ │ │ │→│●│ │ │●│→│●│●│ │●│→│●│●│●│●│
└─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘
┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐
│●│ │ │ │→│●│ │ │●│→│●│ │●│●│→│●│●│●│●│
└─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘
┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐
│ │●│ │ │→│ │●│ │●│→│●│●│ │●│→│●│●│●│●│
└─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘
┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐
│ │ │●│ │→│●│ │●│ │→│●│ │●│●│→│●│●│●│●│
└─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘
┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐
│ │ │ │●│→│●│ │ │●│→│●│●│ │●│→│●│●│●│●│
└─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘
┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐
│ │ │ │●│→│●│ │ │●│→│●│ │●│●│→│●│●│●│●│
└─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘
┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐
│ │ │ │●│→│ │●│ │●│→│●│●│ │●│→│●│●│●│●│
└─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘
我們可以驗證出 T(10) = 61632 而 T(1000) mod 100000007 = 47255094。
請算出 T(1000000) mod 100000007。
--
http://projecteuler.net/problem=364
有 N 個座位排成一排,N 個人依序入座並把座位坐滿,但是入座條件如下:
1. 當有某座位的左右兩個相鄰的座位都沒人時,他就坐這裡。
2. 當已經沒有上述條件的座位時,就退而求其次,挑有一邊沒有坐人的座位坐下。
3. 當已經沒有上述條件的座位時,就挑剩下的座位坐。
使 T(N) 表示為有 N 個人要用上述條件去坐滿 N 個座位時的方法數
下列圖示表示出 T(4) = 8
┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐
│●│ │ │ │→│●│ │●│ │→│●│ │●│●│→│●│●│●│●│
└─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘
┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐
│●│ │ │ │→│●│ │ │●│→│●│●│ │●│→│●│●│●│●│
└─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘
┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐
│●│ │ │ │→│●│ │ │●│→│●│ │●│●│→│●│●│●│●│
└─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘
┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐
│ │●│ │ │→│ │●│ │●│→│●│●│ │●│→│●│●│●│●│
└─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘
┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐
│ │ │●│ │→│●│ │●│ │→│●│ │●│●│→│●│●│●│●│
└─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘
┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐
│ │ │ │●│→│●│ │ │●│→│●│●│ │●│→│●│●│●│●│
└─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘
┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐
│ │ │ │●│→│●│ │ │●│→│●│ │●│●│→│●│●│●│●│
└─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘
┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐ ┌─┬─┬─┬─┐
│ │ │ │●│→│ │●│ │●│→│●│●│ │●│→│●│●│●│●│
└─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘ └─┴─┴─┴─┘
我們可以驗證出 T(10) = 61632 而 T(1000) mod 100000007 = 47255094。
請算出 T(1000000) mod 100000007。
--
Tags:
拼圖
All Comments
By Leila
at 2011-12-26T16:18
at 2011-12-26T16:18
By Isabella
at 2011-12-31T07:11
at 2011-12-31T07:11
By John
at 2011-12-31T19:42
at 2011-12-31T19:42
By Bennie
at 2012-01-01T12:05
at 2012-01-01T12:05
By Vanessa
at 2012-01-05T00:46
at 2012-01-05T00:46
By Audriana
at 2012-01-05T16:53
at 2012-01-05T16:53
By Suhail Hany
at 2012-01-09T12:19
at 2012-01-09T12:19
By Hazel
at 2012-01-11T06:03
at 2012-01-11T06:03
By Franklin
at 2012-01-11T22:24
at 2012-01-11T22:24
By Frederic
at 2012-01-16T11:36
at 2012-01-16T11:36
By Freda
at 2012-01-17T22:39
at 2012-01-17T22:39
By Lauren
at 2012-01-18T18:58
at 2012-01-18T18:58
By John
at 2012-01-22T10:19
at 2012-01-22T10:19
By Barb Cronin
at 2012-01-24T09:49
at 2012-01-24T09:49
By Charlie
at 2012-01-25T10:09
at 2012-01-25T10:09
Related Posts
玩拼圖不用錢,飲料喝免費啦!!~
By Dora
at 2011-12-24T20:37
at 2011-12-24T20:37
翌陽 長頸鹿木頭拼圖
By Charlotte
at 2011-12-23T22:52
at 2011-12-23T22:52
大家最不想重拼的拼圖是?
By Charlie
at 2011-12-23T01:10
at 2011-12-23T01:10
數闇 023
By Lucy
at 2011-12-22T13:08
at 2011-12-22T13:08
ProjectEuler 362 Squarefree factors
By Audriana
at 2011-12-19T19:31
at 2011-12-19T19:31