boj 85

Description

 

Once upon a time,there's a boy whose name is lili.He likes to create many wonderful things.One day, he happens to come to a beautiful garden.There he picks many pretty little stones.Again,his heart tells him that he should use them to create some incredible things!So he decides to put them in a line of boxes,each box has at most one stone,just as the road which he used to walk on in his childhood.But again,he wants to make his works different.So he wants no two adjacent boxes to have stones both.He wonders how many ways that stones be put into boxes.Can you help him to finish his great work?

Input 

multiple cases:

n(0<=n<=100000)the number of the boxes

Output

The number described above MOD 10007.

Sample Input

0

1

Sample Output

1

2

Source

lili 

 

代码:

#include<iostream>
using namespace std;
int arr[100002];
int main()
{
	int n;
	arr[0]=1;
	arr[1]=2;
	for(int i=2;i<=100000;i++)
		arr[i]=(arr[i-1]+arr[i-2])%10007;
	while(~scanf("%d",&n))
		printf("%d\n",arr[n]);
}

 

你可能感兴趣的:(BO)