Pagini recente » Cod sursa (job #90084) | Cod sursa (job #1180031) | Cod sursa (job #1492593) | Cod sursa (job #984037) | Cod sursa (job #2831589)
#include <iostream>
#include <fstream>
using namespace std;
const int BLOCKSIZE = 127, BLOCKBITS = 7, NRBLOCKS = (30000 >> 7) + 1, NMAX = 30000;
ifstream fin("order.in");
ofstream fout("order.out");
int blocks[NRBLOCKS];
bool gone[NMAX];
int getBlock(int pos);
int getFirst(int block);
int getLast(int block);
void rmv(int pos);
void initBlocks(int n);
int main()
{
int n, i, x, j, r, nr, blockind, lastBlock;
fin >> n;
initBlocks(n);
lastBlock = getBlock(n);
r = n;
j = 1;
blockInd = 0;
for (i = 1; i <= n; i++) {
x = i % n;
while (x > blocks[blockind] && blockind < lastBlock) {
x -= blocks[blockind];
blockind++;
}
if (blockind == bloc)
}
return 0;
}
int getBlock(int pos) {
return pos >> BLOCKBITS;
}
int getFirst(int pos) {
int block = getBlock(pos);
return block << BLOCKBITS;
}
int getLast(int pos) {
int block = getBlock(pos);
return (block << BLOCKBITS) + BLOCKSIZE - 1;
}
void rmv(int pos) {
int nrblck = pos >> BLOCKBITS;
blocks[nrblck]--;
gone[pos] = 1;
}
void initBlocks(int n) {
int mxBlck = (n + BLOCKSIZE) >> BLOCKBITS;
int i;
for (i = 0; i < mxBlck; i++)
blocks[i] = BLOCKSIZE;
blocks[mxBlck] = n - i;
}