Put a template here. It's not quite understood anyway.
See the original question to understand the usage!!
#include <cstdio> #include <iostream> #include <algorithm> #include <cmath> #include <cstri Ng> #include <map> using namespace std; #define TIMES ten typedef __int64 LL; map<ll,int>m; ll Random (ll N) {return (double) rand ()/rand_max*n+0.5); } ll multi (ll a,ll b,ll MoD) {ll ans=0; while (b) {if (b&1) {b--; Ans= (ans+a)%mod; } else {b/=2; A= (a+a)%mod; }} return ans; } ll Pow (ll a,ll b,ll MoD) {ll ans=1; while (b) {if (b&1) {b--; Ans=multi (ANS,A,MOD); } else {b/=2; A=multi (A,A,MOD); }} return ans; } BOOL Witness (ll A,ll N) {ll d=n-1; while (!) ( d&1)) d>>=1; LL T=pow (a,d,n); while (d!=n-1 && t!=1 && t!=n-1) {T=multi (t,t,n); d<<=1; } Return T==n-1 | | d&1; } bool Miller_rabin (LL N) {if (n==2) return true; if (n<2| |! (n&1)) return false; for (int i=1;i<=times;i++) {LL a=random (n-2) +1; if (!witness (A,n)) return false; } return true; } ll gcd (ll A,ll b) {if (b==0) return A; return gcd (B,A%B); } ll Pollard_rho (ll N,ll c) {ll x,y,d,i=1,k=2; X=random (n-1) +1; Y=x; while (1) {i++; x= (multi (x,x,n) +c)%n; D=GCD (Y-x,n); if (1<d&&d<n) return D; if (y==x) return n; if (i==k) {y=x; k<<=1; }}} void find (LL n,ll c) {if (n==1) return; if (Miller_rabin (n)) {m[n]++; return; } LL p=n; while (p>=n) P=pollard_rHo (p,c--); Find (P,C); Find (N/P,C); } int main () {int t; cin>>t; while (t--) {LL n; cin>>n; M.clear (); Find (n,2013724); if (M.size () ==1) cout<<1<< "" <<n/m.begin ()->first<<endl; else {LL ans=0; Map<ll,int>::iterator It=m.begin (); for (; It!=m.end (); it++) Ans+=pow (it->first,it->second,n); Cout<<m.size () << "" <<ans<<endl; }} return 0; }
HDU 4344 Large numbers decomposition large prime number judgment