Cod sursa(job #2711907)
Utilizator | Lorintz Alexandru Alex_tz307 | Data | 24 februarie 2021 20:56:38 |
---|---|---|---|
Problema | 12-Perm | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.59 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("12perm.in");
ofstream fout("12perm.out");
const int mod = 1 << 20;
int main() {
int N;
fin >> N;
int x = 2, y = 6, z = 12;
if(N < 3)
fout << N;
else
if(N == 3)
fout << 6;
else
if(N == 4)
fout << 12;
else {
for(int i = 5; i <= N; ++i) {
int t = 2 * (i - 2) + x + z;
while(t >= mod)
t -= mod;
x = y;
y = z;
z = t;
}
fout << z;
}
}