Pagini recente » Cod sursa (job #1856234) | Cod sursa (job #219866) | Cod sursa (job #474049) | Cod sursa (job #1748893) | Cod sursa (job #2065196)
#include<fstream>
#include<cstring>
using namespace std;
ifstream fin("12perm.in");
ofstream fout("12perm.out");
int n, sol[4], S;
static inline int mod( int x ){
return ( x & ( (1<<20) - 1 ) );
}
static inline void Nxt(){
sol[3] = sol[2]; sol[2] = sol[1]; sol[1] = sol[0];
}
int main(){
fin >> n;
sol[0] = 12; sol[1] = 6; sol[2] = 2; sol[3] = 1;
if( n <= 4 ){
fout << sol[4 - n] << "\n";
return 0;
}
for( int i = 5; i <= n; i++ ){
S = mod( mod( sol[0] + sol[2] ) + mod( 2 * ( i - 2 ) ) );
Nxt(); sol[0] = S;
}
fout << sol[0] << "\n";
return 0;
}