Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef MyGO
- #define MyGO
- #include MyGO __FILE__ MyGO
- signed main() {
- fast;
- // debug("meow");
- ll p;
- cin>>p;
- auto fnd=[](ll n)
- {
- for(ll i=1;i<n;i++)
- {
- vector<ll> vis(n);
- ll cnt=0, cur=1;
- while(cur && !vis[cur])
- {
- vis[cur]=1;
- cnt++;
- cur=cur*i%n;
- }
- if(cnt==n-1)
- return i;
- }
- };
- ll g=fnd(p);
- vector<ll> inv(p);
- ll cur=1;
- for(ll i=0;i<p;i++)
- {
- inv[cur]=i;
- cur=cur*g%p;
- }
- vector<ll> cnt(p);
- for(ll i=1;i<p;i++)
- cnt[gcd(i,p-1)]++;
- vector<ll> ans(p-1);
- for(ll i=1;i<=p-1;i++)
- {
- // cout<<i<<' '<<cnt[i]<<'\n';
- for(ll j=0;j<p-1;j+=i)
- ans[j]+=cnt[i]*(i);
- }
- // for (auto x: inv) cerr _ x; cerr _ endl;
- inv[1] = 0;
- // ans[inv[1]] = (p-1)*(p-1);
- // for(ll i=2;i<p;i++)
- // ans[inv[1]] -= ans[inv[i]];
- for(ll i=1;i<p;i++)
- cout<<ans[inv[i]]<<' ';
- return 0;
- }
- #else
- #include <bits/stdc++.h>
- using namespace std;
- #ifdef DEBUG
- #define fast
- #define safe cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n"
- #define debug(a...) debug_(#a, a)
- void debug_(auto s, auto ...a) {
- cerr << "\e[1;32m(" << s << ") = (";
- int f = 0;
- (..., (cerr << (f++ ? ", " : "") << a));
- cerr << ")\e[0m\n";
- }
- #else
- #define fast cin.tie(0)->sync_with_stdio(0)
- #define safe ((void)0)
- #define debug(...) safe
- #endif
- #define _ <<' '<<
- using ll = long long;
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement