Một dãy số f được tạo ra với số thứ n có dạng f(n) = f(n-1) * f(n-2) + f(n-3) với f(1) = 1, f(2) = 1, f(3) = 2. Hãy viết chương trình tìm số thứ n của dãy f. Vì kết quả có thể rất lớn trả về giá trị số đó mod 10 ** 9 + 7. Ví dụ: Với n = 1 thì đầu ra của f(n) = 1. Với n = 2 thì đầu ra của f(n) = 1. Với n = 3 thì đầu ra của f(n) = 2. Với n = 4 thì đầu ra của f(n) = 3.

Các câu hỏi liên quan

Giúp với ToT : Ai đi qua đây nhìn thấy câu hỏi này đừng tiếc thời gian mà hãy giúp em nhé ^^* Em đánh máy mỏi cả tay đó ạ ^-^ II) Complete the sentences with a noun related to one of the following adjectives and verbs followed by an appropriate preposition : *TỪ CHO SẴN* : Admire advise amaze ashamed Cruel discuss improve influence interview lack proud vaccinate 1 . I am against any form of ________________animals and woul support a ban on hunting 2 . Maggie is still in hospital , but there has been a big __________________ her condition in the last couple of days 3 . Maurice took great ____________his cooking , and was always eager to talk about his recipes 4 . The website is full of useful ___________how to lose weight 5 . In her ____________ The Daily Herald , the Finance Minister denied that she plans to raise taxes 6 . I have the greatest ___________ people who work full time and also study for a university degree 7 . We had a long _______________the relative merits of CDs and records 8 . He confessed his _______________ not having spend more time with his children when they were young 9 . I had to have a _____________ typhoid before entering the country 10 . Benny Carter had a significant ___________________ the development of British Jazz 11 . She started in _______________the sight that met her eyes - Dave had shaved all his hair off 12 . There is a severe _________________ affordable housing in the city and many people are homeless