Advertisement
Guest User

Untitled

a guest
May 16th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.41 KB | None | 0 0
  1. #include<windows.h>
  2. #include<iostream>
  3. using namespace std;
  4. long long stepmod(long long x, long long y, long long N)
  5. {
  6.    long long c = 1;
  7.    while (y != 0)
  8.    {
  9.       if (y % 2 == 0)
  10.       {
  11.          y = y / 2;
  12.          x = (x * x) % N;
  13.       }else{
  14.          y--;
  15.          c = (c * x) % N;
  16.       }
  17.    }
  18.    return c;
  19. }
  20. int main()
  21. {
  22.    long long p=1111110001, g=946880040,y=761108829;
  23.    long long a[30]={434691400,1093746706,732399259,842127713,75901103,
  24.       757531051,98409571,359138174,1078289799,839813855,
  25.       736404417,413442390,841226712,1030115485,1058340068,
  26.       236927752,974914967,827373579,310481040,436392971,
  27.       928419514,277333867,372596855,611108999,736586624,
  28.       134257583,1071152880,967485502,57451916,939950943};
  29.    long long b[30]={501112675,1052712262,519308732,58415472,577112821,
  30.       1086359512,73396279,733506096,194954459,144449296,
  31.       891324424,248404362,42989264,904416285,590425478,
  32.       431717666,637553779,848251037,876177134,36913882,
  33.       358189398,734597153,37745997,53227637,610883626,
  34.       789098393,1074367610,1026688045,896392301,1053596158};
  35.    long long m[30], x;
  36.    for (x = 1; ; x++){
  37.       if (stepmod(g, x, p) == y) break;
  38.    }
  39.    for (int i=0; i<30; i++){
  40.       m[i] = (b[i] * stepmod(a[i], x * (p - 2), p)) % p;
  41.       cout << (char)((m[i] >> 16) % 256)
  42.       << (char)((m[i] >> 8) % 256)
  43.       << (char)(m[i] % 256);
  44.    }
  45.    cout<<endl;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement