#include<iostream>
#include<string>
using namespace std;
int M, N;
string first = "0", second = "1", third = "";
void factorial()
{
int temp;
for (int i = 0; i < N; i++)
{
temp = 0;
third.clear();
for (int j = 0; j < first.length(); j++)
{
third += char((temp + first[j] - '0' + second[j] - '0') % 10 + '0');
temp = (temp + first[j] - '0' + second[j] - '0') / 10;
}
if (temp > 0 || second.length() > first.length())
{
if (second.length() > first.length())
temp += second[first.length()] - '0';
third += char(temp + '0');
}
first = second;
second = third;
}
}
int main()
{
cin >> M >> N;
N = N - M;
factorial();
for (int i = third.length() - 1; i >= 0; i--)
cout << third[i];
return 0;
}
洛谷P2437 蜜蜂路线进阶解法
最新推荐文章于 2024-06-21 15:50:59 发布