Advertisement
SorahISA

105335N - [N]ew YoRHa Security

Sep 19th, 2024
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.63 KB | Source Code | 0 0
  1. #ifndef MyGO
  2. #define MyGO
  3. #include MyGO __FILE__ MyGO
  4.  
  5. signed main() {
  6.     fast;
  7.  
  8.     // debug("meow");
  9.    
  10.     ll p;
  11.     cin>>p;
  12.  
  13.     auto fnd=[](ll n)
  14.     {
  15.         for(ll i=1;i<n;i++)
  16.         {
  17.             vector<ll> vis(n);
  18.             ll cnt=0, cur=1;
  19.             while(cur && !vis[cur])
  20.             {
  21.                 vis[cur]=1;
  22.                 cnt++;
  23.                 cur=cur*i%n;
  24.             }
  25.             if(cnt==n-1)
  26.                 return i;
  27.         }
  28.     };
  29.  
  30.     ll g=fnd(p);
  31.  
  32.     vector<ll> inv(p);
  33.     ll cur=1;
  34.     for(ll i=0;i<p;i++)
  35.     {
  36.         inv[cur]=i;
  37.         cur=cur*g%p;
  38.    
  39.     }
  40.     vector<ll> cnt(p);
  41.     for(ll i=1;i<p;i++)
  42.         cnt[gcd(i,p-1)]++;
  43.     vector<ll> ans(p-1);
  44.     for(ll i=1;i<=p-1;i++)
  45.     {
  46.         // cout<<i<<' '<<cnt[i]<<'\n';
  47.         for(ll j=0;j<p-1;j+=i)
  48.             ans[j]+=cnt[i]*(i);
  49.     }
  50.  
  51.     // for (auto x: inv) cerr _ x; cerr _ endl;
  52.     inv[1] = 0;
  53.  
  54.     // ans[inv[1]] = (p-1)*(p-1);
  55.     // for(ll i=2;i<p;i++)
  56.     //     ans[inv[1]] -= ans[inv[i]];
  57.  
  58.     for(ll i=1;i<p;i++)
  59.         cout<<ans[inv[i]]<<' ';
  60.  
  61.     return 0;
  62. }
  63.  
  64. #else
  65.  
  66. #include <bits/stdc++.h>
  67. using namespace std;
  68.  
  69. #ifdef DEBUG
  70. #define fast
  71. #define safe cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n"
  72. #define debug(a...) debug_(#a, a)
  73. void debug_(auto s, auto ...a) {
  74.     cerr << "\e[1;32m(" << s << ") = (";
  75.     int f = 0;
  76.     (..., (cerr << (f++ ? ", " : "") << a));
  77.     cerr << ")\e[0m\n";
  78. }
  79. #else
  80. #define fast cin.tie(0)->sync_with_stdio(0)
  81. #define safe ((void)0)
  82. #define debug(...) safe
  83. #endif
  84. #define _ <<' '<<
  85.  
  86. using ll = long long;
  87.  
  88. #endif
  89.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement