River's lake

查看题解 查看答案
题目描述
Time Limit: 1000 ms
Memory Limit: 256 mb

A peaceful river's lake, just a rumor, began the secret power, the world pattern change slowly, mention who can yitianjian and tulongdao can be at the helm of the world, at this time of the world has become volatile, chaotic lean, there has been a xiaoxia at the helm of the dream of the world, so he decided to set up its own forces, but also constantly looking for a yitianjian and tulongdao, with the forces of xiaoxia growing, one day a man rides a donkey said he konws yitianjian and tulongdao where abouts, the man decided to study  the power of xiaoxai, and then out of the question, the first day two silver wine he can drink 1, the second day will drink 3 ,The third day is two times the first day plus three times the second day,Day n is twice as much as day n minus 2 plus three times as much as day n minus 1(a[n] = a[n-1]*3 + a[n-2]*2),I asked you what the number is on day n

输入输出格式
输入描述:
Multiple sets of input a[1]=1,a[2]=3; M = 1e5; The input give a number n(1<n<1e9)
输出描述:
output a[n]%M
输入输出样例
输入样例#:
3
4
输出样例#:
复制
11
39
编辑器外观×
主题
字号 16px
背景
登录后免费刷此题

提交代码后在此处可查看状态