Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <time.h>
- #include <algorithm>
- #include <cmath>
- using namespace std;
- bool chet = true;
- bool NEG = false;
- vector <vector <int>> vec_bin_gen;
- vector <vector <int>> vec_gen;
- vector <vector <int>> vec_gen_1;
- vector <int> mod = {9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9};
- vector <int> multy (vector <int> U, vector <int> V)
- {
- vector <int> W(U.size() + V.size() + 1);
- if (V.size() > U.size() || (V.size() == U.size() && V > U))
- swap(U, V);
- int m = int(V.size());
- U.push_back(0);
- int t;
- int k = 0;
- for (int j = 0; j < m; j++)
- {
- for (int i = 0; i < U.size(); i++)
- {
- t = U[i] * V[j] + W[i + j] + k;
- W[i + j] = t % 10;
- k = t / 10;
- }
- }
- if (W.size() > 1)
- {
- int n = int(W.size() - 1);
- while (W[n] == 0 && W.size() > 1)
- {
- W.pop_back();
- n--;
- }
- }
- return W;
- }
- vector <int> difference (vector <int> U, vector <int> V)
- {
- int m = int(max(U.size(), V.size()));
- if (U.size() > 1)
- {
- int n = int(U.size() - 1);
- while (U[n] == 0 && U.size() > 1)
- {
- U.pop_back();
- n--;
- }
- }
- if (V.size() > 1)
- {
- int n = int(V.size() - 1);
- while (V[n] == 0 && V.size() > 1)
- {
- V.pop_back();
- n--;
- }
- }
- reverse(U.begin(), U.end());
- reverse(V.begin(), V.end());
- if (V.size() > U.size() || (V.size() == U.size() && V > U))
- {
- swap(U, V);
- NEG = true;
- }
- reverse(U.begin(), U.end());
- reverse(V.begin(), V.end());
- if (V.size() < U.size())
- {
- int r = int(U.size() - V.size());
- for (int i = r; i > 0; i--)
- V.push_back(0);
- }
- vector <int> W;
- int k = 0;
- for (int j = 0; j < U.size(); j++)
- {
- W.push_back((U[j] - V[j] + k + 10) % 10);
- k = (U[j] - V[j] + k - 9) / 10;
- }
- for (int i = 0; i < m; i++)
- W.push_back(0);
- NEG = false;
- if (W.size() > 1)
- {
- int n = int(W.size() - 1);
- while (W[n] == 0 && W.size() > 1)
- {
- W.pop_back();
- n--;
- }
- }
- return W;
- }
- vector <int> difference_1 (vector <int> U, vector <int> V)
- {
- int m = int(max(U.size(), V.size()));
- if (U.size() > 1)
- {
- int n = int(U.size() - 1);
- while (U[n] == 0 && U.size() > 1)
- {
- U.pop_back();
- n--;
- }
- }
- if (V.size() > 1)
- {
- int n = int(V.size() - 1);
- while (V[n] == 0 && V.size() > 1)
- {
- V.pop_back();
- n--;
- }
- }
- reverse(U.begin(), U.end());
- reverse(V.begin(), V.end());
- if (V.size() > U.size() || (V.size() == U.size() && V > U))
- {
- swap(U, V);
- NEG = true;
- }
- reverse(U.begin(), U.end());
- reverse(V.begin(), V.end());
- if (V.size() < U.size())
- {
- int r = int(U.size() - V.size());
- for (int i = r; i > 0; i--)
- V.push_back(0);
- }
- vector <int> W;
- int k = 0;
- for (int j = 0; j < U.size(); j++)
- {
- W.push_back((U[j] - V[j] + k + 10) % 10);
- k = (U[j] - V[j] + k - 9) / 10;
- }
- for (int i = 0; i < m; i++)
- W.push_back(0);
- return W;
- }
- vector <int> addition (vector <int> U, vector <int> V)
- {
- int m = int(max(U.size(), V.size()));
- if (U.size() > 1)
- {
- int n = int(U.size() - 1);
- while (U[n] == 0 && U.size() > 1)
- {
- U.pop_back();
- n--;
- }
- }
- if (V.size() > 1)
- {
- int n = int(V.size() - 1);
- while (V[n] == 0 && V.size() > 1)
- {
- V.pop_back();
- n--;
- }
- }
- if (V.size() > U.size())
- swap(U, V);
- vector <int> W;
- int k = 0;
- int r = int(U.size() - V.size());
- for (int i = r; i > 0; i--)
- V.push_back(0);
- for (int j = 0; j < U.size(); j++)
- {
- W.push_back((U[j] + V[j] + k) % 10);
- k = (U[j] + V[j] + k) / 10;
- }
- for (int i = 0; i < m; i++)
- W.push_back(0);
- return W;
- }
- vector <int> addition_1 (vector <int> U, vector <int> V)
- {
- if (U.size() > 1)
- {
- int n = int(U.size() - 1);
- while (U[n] == 0 && U.size() > 1)
- {
- U.pop_back();
- n--;
- }
- }
- if (V.size() > 1)
- {
- int n = int(V.size() - 1);
- while (V[n] == 0 && V.size() > 1)
- {
- V.pop_back();
- n--;
- }
- }
- if (V.size() > U.size())
- swap(U, V);
- vector <int> W;
- int k = 0;
- int r = int(U.size() - V.size());
- for (int i = r; i > 0; i--)
- V.push_back(0);
- for (int j = 0; j < U.size(); j++)
- {
- W.push_back((U[j] + V[j] + k) % 10);
- k = (U[j] + V[j] + k) / 10;
- }
- if (k == 1)
- W.push_back(k);
- return W;
- }
- vector <int> division (vector <int> U, vector <int> V)
- {
- bool fl = false;
- if (U[0] % 2 == 1)
- chet = false;
- if (U.size() < V.size() || (V.size() == U.size() && V[0] > U[0]))
- {
- vector <int> W;
- W.push_back(0);
- fl = true;
- return W;
- }
- vector <int> W(U.size() + 1);
- if (!fl)
- {
- int cur, ost = 0;
- for (int j = int(U.size() - 1); j >= 0; j--)
- {
- cur = 10 * ost + U[j];
- W[j] = cur / V[0];
- ost = cur % V[0];
- }
- if (W.size() > 1)
- {
- int n = int(W.size() - 1);
- while (W[n] == 0 && W.size() > 1)
- {
- W.pop_back();
- n--;
- }
- }
- }
- return W;
- }
- vector <int> division_1 (vector <int> U, vector <int> V)
- {
- bool fl = false;
- if (U.size() < V.size() || (V.size() == U.size() && V[0] > U[0]))
- {
- vector<int> W;
- W.push_back(0);
- fl = true;
- return W;
- }
- vector <int> W(U.size() + 1);
- if (!fl)
- {
- int cur, ost = 0;
- for (int j = int(U.size() - 1); j >= 0; j--)
- {
- cur = 10 * ost + U[j];
- W[j] = cur / V[0];
- ost = cur % V[0];
- }
- if (W.size() > 1)
- {
- int n = int(W.size() - 1);
- while (W[n] == 0 && W.size() > 1)
- {
- W.pop_back();
- n--;
- }
- }
- }
- return W;
- }
- vector <int> division_mod (vector <int> U, vector <int> V)
- {
- vector <int> vec_mod, W2_2;
- bool fl1 = false;
- if (U[0] == '0' && U.size() == 1)
- {
- fl1 = true;
- vec_mod.push_back(0);
- return vec_mod;
- }
- bool fl = false;
- reverse(V.begin(), V.end());
- reverse(U.begin(), U.end());
- if (U.size() < V.size() || (V.size() == U.size() && V > U))
- {
- fl = true;
- reverse(U.begin(), U.end());
- return U;
- }
- reverse(V.begin(), V.end());
- reverse(U.begin(), U.end());
- vector <int> W(U.size() + 1);
- if (!fl1 && !fl)
- {
- int cur, ost = 0;
- vector <int> Chastnoe(U.size());
- if (V.size() == 1)
- {
- for (int j = int(U.size() - 1); j >= 0; j--)
- {
- cur = 10 * ost + U[j];
- W[j] = cur / V[0];
- ost = cur % V[0];
- }
- vec_mod.push_back(ost);
- return vec_mod;
- }
- else
- {
- int ms = int(U.size() - V.size());
- int d = 10 / (V[V.size() - 1] + 1);
- vector <int> D;
- D.push_back(d);
- U = multy(U, D);
- V = multy(V, D);
- if (ms + V.size() > U.size() - 1)
- U.push_back(0);
- for (int j = ms; j >= 0; j--)
- {
- int qk = (U[j + V.size()] * 10 + U[j + V.size() - 1]) / V[V.size() - 1];
- int rk = (U[j + V.size()] * 10 + U[j + V.size() - 1]) % V[V.size() - 1];
- step1: if (qk == 10 || qk*V[V.size() - 2] > 10 * rk + U[j + V.size() - 2])
- {
- qk--;
- rk += V[V.size() - 1];
- if (rk < 10)
- goto step1;
- }
- vector <int> QK;
- QK.push_back(qk);
- int s = int(j + V.size());
- vector <int> chu(V.size() + 1);
- vector <int> raz(V.size() + 1);
- for (int f = s; f >= j; f--)
- chu[f - j] = U[f];
- vector <int> chupa;
- for (int e = 0; e <= V.size(); e++)
- chupa.push_back(0);
- chupa.push_back(1);
- raz = difference_1(chu, multy(QK, V));
- if (NEG)
- raz = difference_1(chupa, raz);
- Chastnoe[j] = qk;
- if (NEG)
- {
- Chastnoe[j]--;
- raz = addition(V, raz);
- NEG = false;
- }
- for (int f = s; f >= j; f--)
- U[f] = raz[f - j];
- }
- if (Chastnoe.size() > 1)
- {
- int n = int(Chastnoe.size() - 1);
- while (Chastnoe[n] == 0 && Chastnoe.size() > 1)
- {
- Chastnoe.pop_back();
- n--;
- }
- }
- vector <int> U2;
- for (int g = int(V.size() - 1); g >= 0; g--)
- U2.push_back(U[g]);
- reverse(U2.begin(), U2.end());
- vector <int> W2 (U2.size());
- for (int z = int(U2.size() - 1); z >= 0; z--)
- {
- cur = 10 * ost + U2[z];
- W2[z] = cur / D[0];
- ost = cur % D[0];
- }
- if (W2.size() > 1)
- {
- int n = int(W2.size() - 1);
- while (W2[n] == 0 && W2.size() > 1)
- {
- W2.pop_back();
- n--;
- }
- }
- NEG = false;
- W2_2 = W2;
- }
- }
- return W2_2;
- }
- vector <int> division_chast (vector <int> U, vector <int> V)
- {
- vector <int> vec_mod, Chastnoe_2;
- bool fl1 = false;
- if (U[0] == '0' && U.size() == 1)
- {
- fl1 = true;
- vec_mod.push_back(0);
- return vec_mod;
- }
- bool fl = false;
- reverse(V.begin(), V.end());
- reverse(U.begin(), U.end());
- if (U.size() < V.size() || (V.size() == U.size() && V > U))
- {
- fl = true;
- vec_mod.push_back(0);
- return vec_mod;
- }
- reverse(V.begin(), V.end());
- reverse(U.begin(), U.end());
- vector <int> W(U.size() + 1);
- if (!fl1 && !fl)
- {
- int cur, ost = 0;
- vector <int> Chastnoe(U.size());
- if (V.size() == 1)
- {
- for (int j = int(U.size() - 1); j >= 0; j--)
- {
- cur = 10 * ost + U[j];
- W[j] = cur / V[0];
- ost = cur % V[0];
- }
- if (W.size() > 1)
- {
- int n = int(W.size() - 1);
- while (W[n] == 0 && W.size() > 1)
- {
- W.pop_back();
- n--;
- }
- }
- return W;
- }
- else
- {
- int ms = int(U.size() - V.size());
- int d = 10 / (V[V.size() - 1] + 1);
- vector <int> D;
- D.push_back(d);
- U = multy(U, D);
- V = multy(V, D);
- if (ms + V.size() > U.size() - 1)
- U.push_back(0);
- for (int j = ms; j >= 0; j--)
- {
- int qk = (U[j + V.size()] * 10 + U[j + V.size() - 1]) / V[V.size() - 1];
- int rk = (U[j + V.size()] * 10 + U[j + V.size() - 1]) % V[V.size() - 1];
- step1: if (qk == 10 || qk*V[V.size() - 2] > 10 * rk + U[j + V.size() - 2])
- {
- qk--;
- rk += V[V.size() - 1];
- if (rk < 10)
- goto step1;
- }
- vector <int> QK;
- QK.push_back(qk);
- int s = int(j + V.size());
- vector <int> chu(V.size() + 1);
- vector <int> raz(V.size() + 1);
- for (int f = s; f >= j; f--)
- chu[f - j] = U[f];
- vector <int> chupa;
- for (int e = 0; e <= V.size(); e++)
- chupa.push_back(0);
- chupa.push_back(1);
- raz = difference_1(chu, multy(QK, V));
- if (NEG)
- raz = difference_1(chupa, raz);
- Chastnoe[j] = qk;
- if (NEG)
- {
- Chastnoe[j]--;
- raz = addition(V, raz);
- NEG = false;
- }
- for (int f = s; f >= j; f--)
- U[f] = raz[f - j];
- }
- if (Chastnoe.size() > 1)
- {
- int n = int(Chastnoe.size() - 1);
- while (Chastnoe[n] == 0 && Chastnoe.size() > 1)
- {
- Chastnoe.pop_back();
- n--;
- }
- }
- NEG = false;
- Chastnoe_2 = Chastnoe;
- }
- }
- return Chastnoe_2;
- }
- vector <int> stepen_mod (vector <int> U, vector <int> V, vector <int> mod1)
- {
- vector <int> Y;
- Y.push_back(1);
- vector <int> N = V;
- vector <int> Z = U;
- vector <int> del;
- del.push_back(2);
- while (!(N.size() == 1 && N[0] == 0))
- {
- N = division(N, del);
- if (chet)
- {
- Z = multy(Z, Z);
- Z = division_mod(Z, mod1);
- }
- else
- {
- Y = multy(Y, Z);
- Y = division_mod(Y, mod1);
- if (N.size() == 1 && N[0] == 0)
- break;
- Z = multy(Z, Z);
- Z = division_mod(Z, mod1);
- chet = true;
- }
- }
- Y = division_mod(Y, mod1);
- if (Y.size() > 1)
- {
- int n = int(Y.size() - 1);
- while (Y[n] == 0 && Y.size() > 1)
- {
- Y.pop_back();
- n--;
- }
- }
- chet = true;
- return Y;
- }
- vector <int> generator (int k)
- {
- srand(time(NULL));
- vector <int> rnd;
- step1:
- for (int i = 0; i < k ; i++)
- {
- int r = rand() % 10;
- rnd.push_back(r);
- }
- reverse(rnd.begin(), rnd.end());
- if (rnd.size() > 1)
- {
- int n = int(rnd.size() - 1);
- while (rnd[n] == 0 && rnd.size() > 1)
- {
- rnd.pop_back();
- n--;
- }
- }
- reverse(rnd.begin(), rnd.end());
- for (int i = 0; i < vec_gen.size(); i++)
- if (rnd == vec_gen[i])
- {
- rnd.clear();
- goto step1;
- }
- vec_gen.push_back(rnd);
- return rnd;
- }
- vector <int> generator_1 (int k)
- {
- vector <int> rnd;
- step2:
- for (int i = 0; i < k; i++)
- {
- int r = rand() % 10;
- rnd.push_back(r);
- }
- reverse(rnd.begin(), rnd.end());
- if (rnd.size() > 1)
- {
- int n = int(rnd.size() - 1);
- while (rnd[n] == 0 && rnd.size() > 1)
- {
- rnd.pop_back();
- n--;
- }
- }
- reverse(rnd.begin(), rnd.end());
- for (int i = 0; i < vec_gen_1.size(); i++)
- if (rnd == vec_gen_1[i])
- {
- rnd.clear();
- goto step2;
- }
- vec_gen_1.push_back(rnd);
- return rnd;
- }
- vector <int> generator_2 (int &k)
- {
- vector <int> rnd;
- if (k == 1)
- {
- rnd.push_back(1);
- return rnd;
- }
- step1:
- rnd.push_back(1);
- for (int i = 0; i < k - 2; i++)
- {
- int r = rand() % 2;
- rnd.push_back(r);
- }
- rnd.push_back(1);
- for (int i = 0; i < vec_bin_gen.size(); i++)
- if (rnd == vec_bin_gen[i])
- {
- rnd.clear();
- goto step1;
- }
- vec_bin_gen.push_back(rnd);
- return rnd;
- }
- vector <int> to10 (vector <int> c)
- {
- int size = int(c.size());
- vector <int> to10_c(log2(size) + 1), vec_2, stepen;
- vec_2.push_back(2);
- for (int i = 0; i < size; i++)
- {
- int st = size - i - 1;
- string ST;
- ST = to_string(st);
- for (int j = int(ST.size() - 1); j >= 0; j--)
- {
- string step_str;
- step_str = ST.substr(j, 1);
- int step_ch = atoi(step_str.c_str());
- stepen.push_back(step_ch);
- }
- vector <int> vec;
- vec.push_back(c[i]);
- to10_c = addition_1(to10_c, multy(vec, stepen_mod(vec_2, stepen, mod)));
- vec.clear();
- stepen.clear();
- }
- if (to10_c.size() > 1)
- {
- int n = int(to10_c.size() - 1);
- while (to10_c[n] == 0 && to10_c.size() > 1)
- {
- to10_c.pop_back();
- n--;
- }
- }
- return to10_c;
- }
- bool compare_for_v (vector <int> &V, vector <int> &U)
- {
- if (V.size() < U.size())
- return true;
- if (V.size() > U.size())
- return false;
- if (V == U)
- return false;
- for (int g = 0; g < V.size(); g++)
- {
- if (V[g] > U[g])
- return false;
- else
- if (V[g] < U[g])
- return true;
- }
- return true;
- }
- bool isprime (vector <int> c)
- {
- if (c.size() == 1 && (c[0] == 0 || c[0] == 1 || c[0] == 2))
- return true;
- vector <int> q, a, vec_1, vec_2;
- a.push_back(0);
- vec_1.push_back(1);
- vec_2.push_back(2);
- int count = 0;
- if (c != vec_1)
- {
- q = difference(c, vec_1);
- do { q = division_chast(q, vec_2); count++; } while (q[0] % 2 == 0);
- vector <int> vec_i, vec_i_max, vec_count;
- vec_i.push_back(1);
- vec_i_max = difference(c, vec_1);
- vec_count.push_back(4);
- vec_count.push_back(0);
- if (compare_for_v(vec_count, vec_i_max))
- vec_i_max = vec_count;
- for (vec_i; compare_for_v(vec_i, vec_i_max); vec_i = addition_1(vec_i, vec_1))
- {
- vector <int> diff = difference(c, vec_1);
- reverse(diff.begin(), diff.end());
- while (compare_for_v(a, vec_1) || compare_for_v(diff, a))
- a = generator_1(int(difference(c, vec_1).size()));
- reverse(a.begin(), a.end());
- if (stepen_mod(a, difference(c, vec_1), c) != vec_1)
- return false;
- a = stepen_mod(a, q, c);
- if (a != vec_1)
- {
- for (int e = 0; e < count; e++)
- if (a != vec_1 && a != difference(c, vec_1))
- a = division_mod(multy(a, a), c);
- if (a == vec_1)
- return false;
- }
- a.clear();
- }
- return true;
- }
- else
- return false;
- }
- int main ()
- {
- setlocale(LC_ALL, "Russian");
- string bit;
- cout << "Введите битность числа р = ";
- cin >> bit;
- vector <int> bit_p, p_control;
- for (int i = int(bit.size() - 1); i >= 0; i--)
- bit_p.push_back(atoi(bit.substr(i, 1).c_str()));
- int bit1 = atoi(bit.c_str());
- if (bit1 <= 3)
- {
- cout << "Ошибка" << endl;
- return 0;
- }
- bit1 = bit1 / 2;
- vector <int> vec_1, vec_2, q;
- vec_1.push_back(1);
- vec_2.push_back(2);
- step3:
- q = generator_2(bit1);
- q = to10(q);
- if (!isprime(q))
- {
- vec_gen_1.clear();
- goto step3;
- }
- vector <int> down_gr_p, up_gr_p, down_gr_s, up_gr_s, gr1 = down_gr_s, gr2 = up_gr_s, p;
- down_gr_p = stepen_mod(vec_2, difference(bit_p, vec_1), mod);
- up_gr_p = stepen_mod(vec_2, bit_p, mod);
- down_gr_s = division_chast(difference(down_gr_p, vec_1), q);
- up_gr_s = addition_1(division_chast(difference(up_gr_p, vec_1), q), vec_1);
- reverse(down_gr_p.begin(), down_gr_p.end());
- reverse(up_gr_p.begin(), up_gr_p.end());
- reverse(gr1.begin(), gr1.end());
- reverse(gr2.begin(), gr2.end());
- vector <int> s, predel;
- s.push_back(1);
- vector <vector <int>> ss;
- predel.push_back(int(ss.size()));
- step4:
- s = generator(int(up_gr_s.size()));
- if ((!compare_for_v(s, gr1) && !compare_for_v(gr2, s)) && s[s.size() - 1] % 2 == 0)
- {
- vector <int> S = s;
- reverse(S.begin(), S.end());
- p = addition_1(multy(q, S), vec_1);
- vector <int> V1, V2, V3;
- V1 = stepen_mod(addition_1(multy(vec_2, q), vec_1), vec_2, mod);
- V2 = stepen_mod(vec_2, multy(q, S), p);
- V3 = stepen_mod(vec_2, S, p);
- reverse(V1.begin(), V1.end());
- reverse(V2.begin(), V2.end());
- reverse(V3.begin(), V3.end());
- reverse(p.begin(), p.end());
- if (compare_for_v(p, V1) && (V2 == vec_1) && (V3 != vec_1) && compare_for_v(p, up_gr_p) && compare_for_v(down_gr_p, p))
- p_control = p;
- else
- {
- vector <int> vec = difference(difference(up_gr_s, down_gr_s), division_1(difference(up_gr_s, down_gr_s), vec_2));
- bool fl = false;
- if (predel.size() < vec.size())
- fl = true;
- if (predel.size() > vec.size())
- fl = false;
- if (predel == vec)
- fl = false;
- for (int g = 0; g < predel.size(); g++)
- if (predel[g] > vec[g])
- fl = false;
- else
- if (predel[g] < vec[g])
- fl = true;
- if (fl)
- ss.push_back(S);
- predel = addition_1(predel, vec_1);
- goto step4;
- }
- }
- else
- goto step4;
- vector <int> vec = difference(difference(up_gr_s, down_gr_s), division_1(difference(up_gr_s, down_gr_s), vec_2));
- bool fl = false;
- if (predel.size() < vec.size())
- fl = true;
- if (predel.size() > vec.size())
- fl = false;
- if (predel == vec)
- fl = false;
- for (int g = 0; g < predel.size(); g++)
- if (predel[g] > vec[g])
- fl = false;
- else
- if (predel[g] < vec[g])
- fl = true;
- if (!fl)
- {
- vec_bin_gen.clear();
- vec_gen.clear();
- vec_gen_1.clear();
- goto step3;
- }
- vector <int> g;
- g.push_back(1);
- cout << "p = ";
- for (int i = 0; i < p_control.size(); i++)
- cout << p_control[i];
- cout << endl;
- cout << "q = ";
- for (int i = 0; i < q.size(); i++)
- cout << q[i];
- cout << endl;
- reverse (p_control.begin(), p_control.end());
- while (g == vec_1)
- {
- vector <int> a, p_2;
- p_2 = difference(p_control, vec_2);
- reverse(p_2.begin(), p_2.end());
- while (compare_for_v(a, vec_2) || compare_for_v(p_2, a))
- a = generator_1(int(p_control.size()));
- vector <int> p_1, p_q;
- p_1 = difference(p_control, vec_1);
- p_q = division_chast(p_1, q);
- g = stepen_mod(a, p_q, p_control);
- }
- reverse(g.begin(), g.end());
- cout << "g = ";
- for (int i = 0; i < g.size(); i++)
- cout << g[i];
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement