Pagini recente » Cod sursa (job #3248829) | Cod sursa (job #387757) | Cod sursa (job #1048206) | Cod sursa (job #2535266) | Cod sursa (job #2562268)
#include <fstream>
#include <stdlib.h>
#include <cstdio>
using namespace std;
ofstream fout ("congr.out");
const long long MAXN = 600001;
pair <long long,long long> a[MAXN];
long long n,p,sum;
#include <stdio.h>
#include <ctype.h>
class InParser {
private:
FILE *fin;
char *buff;
int sp;
char read_ch() {
++sp;
if (sp == 4096) {
sp = 0;
fread(buff, 1, 4096, fin);
}
return buff[sp];
}
public:
InParser(const char* nume) {
fin = fopen(nume, "r");
buff = new char[4096]();
sp = 4095;
}
InParser& operator >> (int &n) {
char c;
while (!isdigit(c = read_ch()) && c != '-');
int sgn = 1;
if (c == '-') {
n = 0;
sgn = -1;
} else {
n = c - '0';
}
while (isdigit(c = read_ch())) {
n = 10 * n + c - '0';
}
n *= sgn;
return *this;
}
InParser& operator >> (long long &n) {
char c;
n = 0;
while (!isdigit(c = read_ch()) && c != '-');
long long sgn = 1;
if (c == '-') {
n = 0;
sgn = -1;
} else {
n = c - '0';
}
while (isdigit(c = read_ch())) {
n = 10 * n + c - '0';
}
n *= sgn;
return *this;
}
};
InParser fin ("congr.in");
int main() {
fin >> p;
n = 2*p-1;
for(long long i = 1; i <= n; ++i) {
fin >> a[i].first,a[i].second = i;
a[i].first %= p;
if(i <= p)
sum += a[i].first;
}
srand(unsigned(time(0)));
while( sum % p) {
int p1 = rand() % p + 1;
int p2 = rand() % (p-1) + p+1;
sum += (-a[p1].first + a[p2].first+p) % p;
swap(a[p1],a[p2]);
}
for ( int i = 1; i <= p; ++i)
fout << a[i].second << " ";
}