Pagini recente » Cod sursa (job #2536412) | Cod sursa (job #144550) | Cod sursa (job #3296174) | Cod sursa (job #463) | Cod sursa (job #2098218)
#include <fstream>
#include <algorithm>
#define VAL 105
#define MOD (1 << 20)
using namespace std;
ifstream fin("12perm.in");
ofstream fout("12perm.out");
int N, i, j;
int ANS, a, b, c;
int main()
{
fin >> N;
if (N==1)
fout << 1;
if (N==2)
fout << 2;
if (N==3)
fout << 6;
if (N==4)
fout << 12;
if (N>5)
{
a=12;
b=6;
c=2;
for (i=5; i<=N; i++)
{
ANS=a+c+2*i-4;
ANS%=MOD;
c=b;
b=a;
a=ANS;
}
fout << ANS << '\n';
}
fin.close();
fout.close();
return 0;
}