Mistři v programování na #hovnokod

C/C++ #37

long gr, ri, r1, r2, y, z, z_rev;
	for (i = 2; i < qr_count; i++) {
		step = 0;
 		ri = r[i];
		gr = - mpz_fdiv_ui(lowM, pm[i][step]);
		r1 = gr + ri;
		r2 = gr + pm[i][step] - ri;
		if (r1 < 0) {
			r1 += pm[i][step];
		}
		if (r2 < 0) {
			r2 += pm[i][step];
		}
		while (r1 < (long) Ml2) {
			sieve[r1][i] += 1;
			r1 += pm[i][step];
		}
		while (r2 < (long) Ml2) {
			sieve[r2][i] += 1;
			r2 += pm[i][step];
		}
		for (step = 1; step < degr[i]; step++) {
			gr = - mpz_fdiv_ui(lowM, pm[i][step]);
			y = ri*ri;
			y -= Npm[i][step];
			y = y/( (long) pm[i][step-1]);
			if (y < 0) { y += pm[i][step]; }
			z_rev = (ri<<1) % QR[i];
			//?IOOA?EOO ?OI?AOEO IA UAAEEIE?AIEA
			if (z_rev == 0) { y = 0; }
			else {
				z = 1;	
				while ((z_rev*z % QR[i]) != 1) { z++;}
				y *= z*pm[i][step-1];
				y = y % pm[i][step];
			}
			ri -= y;
			if (ri < 0) { ri += pm[i][step]; }
			r1 = gr+ri;
			r2 = gr+pm[i][step]-ri;
			if (r1 < 0) { r1 += pm[i][step]; }
			if (r2 < 0) { r2 += pm[i][step]; }
			while (r1 < (long) Ml2) {
				sieve[r1][i] += 1;
				r1 += pm[i][step];
			}
			while (r2 < (long) Ml2) {
				sieve[r2][i] += 1;
				r2 +=pm[i][step];
			}
		}
	}

Anonymous,