Pagini recente » Cod sursa (job #877699) | Cod sursa (job #2287191) | Cod sursa (job #2321071) | Cod sursa (job #922453) | Cod sursa (job #2595889)
#include <fstream>
#include <vector>
using namespace std;
ifstream cin("curcubeu.in");
class OutParser {
private:
static const int buffSZ = (1 << 15);
ofstream File;
char buff[buffSZ];
int buffPos;
vector <int> digits;
void _advance() {
if (++buffPos == buffSZ) {
File.write(buff, buffSZ);
buffPos = 0;
}
}
void printChar(char no) {
buff[buffPos] = no;
_advance();
}
public:
OutParser(const char *FileName) {
File.open(FileName);
digits.resize(11);
buffPos = 0;
}
~OutParser() {
File.write(buff, buffPos);
buffPos = 0;
}
OutParser& operator <<(char ch) {
printChar(ch);
return *this;
}
OutParser& operator <<(int no) {
int idx = 0;
if (no == 0)
digits[++idx] = 0;
while (no) {
digits[++idx] = no % 10;
no /= 10;
}
for (; idx; --idx)
printChar(digits[idx] + '0');
return *this;
}
};
OutParser cout("curcubeu.out");
int n,l,r,v[1000005],a[1000005],b[1000005],c[1000005],ans[1000005];
int main()
{
cin>>n>>a[1]>>b[1]>>c[1];
for(int i=2;i<n;i++){
a[i]=(1LL*a[i-1]*i)%n;
b[i]=(1LL*b[i-1]*i)%n;
c[i]=(1LL*c[i-1]*i)%n;
}
for(int i=n-1;i>0;i--){
l=min(a[i],b[i]);
r=max(a[i],b[i]);
for(int j=l;j<=r;j++){
if(!ans[j]){
ans[j]=c[i];
v[j]=r;
}
else{
j=v[j];
}
}
}
for(int i=1;i<n;i++){
cout << ans[i];
cout<<'\n';
}
return 0;
}