Pagini recente » Cod sursa (job #1438753) | Cod sursa (job #1413485) | Cod sursa (job #2468000) | Cod sursa (job #1393334) | Cod sursa (job #1395951)
#include <fstream>
using namespace std;
ifstream fin("12perm.in");
ofstream fout("12perm.out");
const int kMax = 15000000;
const int kMod = (1 << 20);
int dp[kMax];
int main()
{
int n; fin >> n;
dp[1] = 1;
dp[2] = 2;
dp[3] = 6;
dp[4] = 12;
for (int i = 5; i <= n; ++i)
dp[i] = (dp[i - 1] + dp[i - 3] + 2 * (i - 2)) & (kMod - 1);
fout << dp[n] << '\n';
return 0;
}