SPOJ Factorial Solution | Classical Problem 8 Solution | SPOJ - Online Judge Solution

Latest

It is a free Online judges problems solution list. Here you can find UVA online Judge Solution, URI Online Judge Solution, Code Marshal Online Judge Solution, Spoz Online Judge Problems Solution

Wednesday, May 10, 2017

SPOJ Factorial Solution | Classical Problem 8 Solution | SPOJ

SPOJ Factorial Solution | Classical Problem 8 Solution | SPOJ


Sphere Online Judge Solution  Factorial
Sphere Online Judge Main Problem Link - Factorial  Solution - http://www.spoj.com/problems/FCTRL/

Problem Name: SPOJ Problem Factorial
Problem Number : SPOJ Problem 11 Factorial
Online Judge : SPOJ Solution
Solution Language : C,CPP, CPP14
Level : Classical

SPOJ Factorial Solution | Classical Problem 8 Solution | SPOJ


SPOJ Factorial Solution Code in CPP 14:


#include <cstdio>

using namespace std;

int main(){    
    int M[12]={5,25,125,625,3125,15625,78125,390625,1953125,9765625,48828125,244140625};
    
    int T,N,cont;
    
    scanf("%d",&T);
    
    for(int tc=1;tc<=T;tc++){
        scanf("%d",&N);
        
        cont=0;
        
        for(int j=0;j<12;j++) cont+=N/M[j];
        
        printf("%d\n",cont);
    }
    
    return 0;
}


SPOJ Factorial Solution Code in ANSI C:

#include <stdio.h>

int main(){    
    int M[12]={5,25,125,625,3125,15625,78125,390625,1953125,9765625,48828125,244140625};
    
    int T, N, cont, tc, j;
    
    scanf("%d",&T);
    
    for(tc=1;tc<=T;tc++){
        scanf("%d",&N);
        
        cont=0;
        
        for(j=0;j<12;j++) 
              cont+=N/M[j];
        
        printf("%d\n",cont);
    }
    
    return 0;
}


Tags: Sphere Online Judge Solutions, SPOJ Factorial solution , Sphere online Judge Factorial Solution

No comments:

Post a Comment