Mn = ( Mn-1 + Mn-2 ) % 10007
因为
*F(n) = X1 * 10007 + Mn
F(n+1) = X2 * 10007 +Mn+1
F(n+2) = F(n) + F(n+1)
=(X1 + X2)+100007 + Mn + Mn+1
Mn+2 = F(n+2) / 10007 = Mn + Mn+1
所以 Mn = ( Mn-1 + Mn-2 ) % 10007
#include <iostream>
int main()
{
int a = 1,b = 0, sum = 0,t = 0, n;
std::cin >> n;
while ( ++t <= n )
{
sum = ( a + b ) % 10007;
a = b;
b = sum;
}
std::cout << sum;
return 0;
}
Yicay
发布了1 篇原创文章 · 获赞 0 · 访问量 12
私信
关注