Pagini recente » Cod sursa (job #3142117) | Cod sursa (job #1836034) | Cod sursa (job #2283655) | Cod sursa (job #494070) | Cod sursa (job #2098216)
#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;
c=b;
b=a;
a=ANS;
}
fout << ANS << '\n';
}
fin.close();
fout.close();
return 0;
}