Mai intai trebuie sa te autentifici.
Cod sursa(job #1391033)
| Utilizator | Data | 17 martie 2015 16:10:30 | |
|---|---|---|---|
| Problema | 12-Perm | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <fstream>
using namespace std;
ifstream fin ("12perm.in");
ofstream fout ("12perm.out");
const int MOD = (1 << 20);
int N, a, b, c;;
int main()
{
fin >> N;
a = 2;
b = 6;
c = 12;
for (int i = 5; i <= N; i++)
{
a = (c + a + ((i - 2) << 1)) % MOD;
swap (a, c);
swap (a, b);
}
if (N == 1) fout << "1\n";
else if (N == 2) fout << a << '\n';
else if (N == 3) fout << b << '\n';
else fout << c << '\n';
fout.close();
return 0;
}
