Codeforcesgym 100753F Divisions

Source: Internet
Author: User
Tags mul

Divisionstime limit:2000msmemory limit:262144kbthis problem'll be judged onCodeforcesgym. Original id:100753f
64-bit integer IO format: %i64d Java class name: (any) Solving problems: Decomposition of large number of factors
1#include <bits/stdc++.h>2 using namespacestd;3typedefLong LongLL;4 Const intMAXN =100001;5 ll Mul (ll a,ll b,ll MoD) {6     if(!a)return 0;7     return((a&1) *b%mod + (Mul (a>>1, B,mod) <<1)%mod)%MoD;8 }9 ll Quickpow (ll a,ll d,ll N) {TenLL ret =1; One      while(d) { A         if(d&1) ret =Mul (ret,a,n); -D >>=1; -A =Mul (a,a,n); the     } -     returnret; - } - BOOLCheck (LL a,ll d,ll N) { +     if(n = = a)return true; -      while(~d&1) d >>=1; +LL T =Quickpow (a,d,n); A      while(D < n1&& T! =1&& T! = N1) { att =Mul (t,t,n); -D <<=1; -     } -     return(d&1) || t = = n1; - } - BOOLIsP (LL N) { in     if(n = =2)return true; -     if(N <2||0= = (n&1))return false; to     Static intp[5] = {2,3,7, A,24251}; +      for(inti =0; I <5; ++i) -         if(!check (p[i],n-1, N))return false; the     return true; * } $ ll gcd (ll A,ll b) {Panax Notoginseng     if(A <0)returnGCD (-A,B);//special attention, no, this tle. -     returnB?GCD (b,a%b): A; the } + ll Pollard_rho (ll N,ll c) { ALL i =1, k =2, x = rand ()%n,y =x; the      while(true) { +x = (Mul (x,x,n) + c)%N; -LL d = gcd (Y-x,n); $         if(d! =1&& d! = N)returnD; $         if(y = = x)returnN; -         if(++i = =k) { -y =x; theK <<=1; -         }Wuyi     } the } - LL Fac[maxn],tot; Wu voidfactorization (LL N) { -     if(IsP (n)) { Aboutfac[tot++] =N; $         return; -     } -LL p =N; -      while(P >= N) p = Pollard_rho (P,rand ()% (N-1)+1); A factorization (p); +Factorization (n/p); the } -Unordered_map<ll,ll>UMP; $ intMain () { the LL x; theSrand (Time (0)); the      while(~SCANF ("%i64d",&x)) { thetot =0; -         if(x = =1) { inPuts"1"); the             Continue; the         } About         if(IsP (x)) { thePuts"2"); the             Continue; the         } + factorization (x); - ump.clear (); the          for(inti =0; i < tot; ++i)Bayiump[fac[i]]++; theUnsignedLong LongRET =1; the          for(Auto &it:ump) ret *= (It.second +1); -printf"%i64u\n", ret); -     } the     return 0; the } the /* the 999999999999999989 - 100000007700000049 the */
View Code

Codeforcesgym 100753F Divisions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.