- /****************##### بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم #####******************
- __________________________________________________________________________
- ###################### Ya-Seen Arafat(ACWizard) #########################
- ###################### UAP-CSE-33B #########################
- *************************************************************************/
- #include <bits/stdc++.h>
- #define ll long long
- #define S 1000003
- using namespace std;
- bool prime[S];
- ll primeNum[S];
- int ind;
- void seive(){
- prime[0] = prime[1] = false;
- int sqr = sqrt(S);
- for(int i = 2; i <= sqr; i++){
- if(prime[i]){
- for(int j = i+i; j <= S; j+=i)prime[j] = false;
- }
- }
- ind = 0;
- for(int i = 0; i <= S; i++)if(prime[i])primeNum[ind++] = i;
- }
- ll numDivisor(ll raw){
- ll tot = 0, prev = 0LL, cn = 0LL;
- for(int i = 0; i < ind && primeNum[i]*primeNum[i] <= raw; i++){
- bool flag = true;
- while(raw%primeNum[i] == 0LL){
- cn++;
- raw /= primeNum[i];
- }
- tot = (prev*cn) + (prev+cn);
- prev = tot;
- if(raw != 1)cn = 0LL;
- }
- if(!cn)tot += tot + 1;
- return tot;
- }
- int main(){
- int t, cs = 0;
- memset(prime, true, sizeof(prime));
- seive();
- ll n;
- scanf("%d", &t);
- while(t--){
- scanf("%lld", &n);
- if(n == 1LL){
- printf("Case %d: 0\n", ++cs);
- continue;
- }
- ll ans = numDivisor(n);
- printf("Case %d: %lld\n", ++cs, ans);
- }
- return 0;
- }
Sunday, February 28, 2016
LightOJ - Trailing Zeroes (I)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment