Cod sursa(job #2573743)
Utilizator | Data | 5 martie 2020 18:58:17 | |
---|---|---|---|
Problema | 12-Perm | Scor | 5 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.48 kb |
#include <fstream>
using namespace std;
ifstream fin("12perm.in");
ofstream fout("12perm.out");
int main()
{
int i,n,ti1,ti2,ti3,ti;
fin>>n;
if(n<=4)
{
if(n==1) fout<<1;
else if(n==2) fout<<2;
else if(n==3) fout<<6;
else fout<<12;
}
ti1=12;
ti2=6;
ti3=2;
for(i=5;i<=n;i++)
{
ti=ti1+ti3+2*(i-2);
ti3=ti2;
ti2=ti1;
ti1=ti;
}
fout<<ti;
return 0;
}