3164 mass factor decomposition
time limit: 1 sspace limit: 256000 KBtitle level: Golden Gold SolvingView Run ResultsTitle Description
Description
(majority) give the number of T, and find out the number of its mass factor.
The data is not pit, the difficulty is reduced.
Enter a description
Input Description
First line T
After T-line data
Output description
Output Description
T-line decomposition results (number of mass factors)
Sample input
Sample Input
2
11
6
Sample output
Sample Output
1
2
Data range and Tips
Data Size & Hint
11 itself is a prime number, so count into it.
By the way, hint: t<=100000. Each number is less than a long long unsigned hehe
Category labels
Tags Click here to expandEnumerating Programming ability problems
first, directly on the only decomposition theorem, the result wa+tle??
WA Code:
#include <cstdio>#include<iostream>#include<cmath>#include<vector>using namespacestd;#definell unsigned long long#definePir pair<ll,ll>Vector<pir>F;inlineConstll read () {Register LL x=0; RegisterCharCh=GetChar (); while(ch<'0'|| Ch>'9') ch=GetChar (); while(ch>='0'&&ch<='9') x=x*Ten+ch-'0', ch=GetChar (); returnx;}voidDeal (ll x) {f.clear (); ll M=floor (sqrt (x) +0.5); for(LL i=2; i<=m;i++){ if(x%i)Continue; LL Q=0; while(x%i==0) q++,x/=i; F.push_back (Make_pair (i,q)); } if(x>1) F.push_back (Make_pair (x,1)); printf ("%d\n", F.size ());}intMain () {ll t,n; T=read (); while(t--) n=read (), Deal (n); return 0;}
violence.
AC Code:
#include <iostream>using namespacestd;intMain () {Ios::sync_with_stdio (false); intTLong LongN; CIN>>T; while(t--) {cin>>N; inttot=0; for(intI=2; i<=n;i++){ if(n==1) Break; if(n%i==0){ Do{n/=i; Tot++; } while(n%i==0); }} cout<<tot<<Endl; } return 0;}
3164 mass factor decomposition