Cod sursa(job #2098216)
Utilizator | Data | 2 ianuarie 2018 16:08:01 | |
---|---|---|---|
Problema | 12-Perm | Scor | 5 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.6 kb |
#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;
}