Cod sursa(job #122617)
| Utilizator | Data | 13 ianuarie 2008 09:56:02 | |
|---|---|---|---|
| Problema | 12-Perm | Scor | 50 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.43 kb |
#include <fstream.h>
//using namespace std;
int main(){
ifstream fin("12perm.in");
ofstream fout("12perm.out");
long N;
long b=2,c=6,d=12,Max=1048576;
fin>>N;
for (int i=5;i<=N;i++)
{
long aux=d;
d=(d+b+2*(i-2));
b=c%Max;
c=aux %Max;
}
if (N==4)
fout<<12;
if (N==3)
fout<<6;
if (N==2)
fout<<2;
if (N==1)
fout<<1;
fout<<d % Max;
fout<<"\n";
fin.close();
fout.close();
return 0;
}
