MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / solve

Function solve

Spoj_problems/FCTRL2/solution.cpp:46–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46void solve(){
47 // solution starts from here
48 int n, i;
49 cin>>n;
50
51
52 if ( vec_2d[n][0] != 0 ){ //Print factorial, if its already calculated
53 print_fact(n);
54 }
55 else{
56 for (i=n-1; i>=1; i--) // Check for calculated factorial of immediate prev num (less than num)
57 if (vec_2d[i][0] != 0)
58 break;
59
60 for (int k=i+1; k<=n; k++){ // Calculate factorial from the point, its not present till n
61 calc_fact(k);
62 }
63 print_fact(n); // Print the factorial of n
64 }
65
66}
67
68int main(){
69 int tt;

Callers 1

mainFunction · 0.70

Calls 2

print_factFunction · 0.85
calc_factFunction · 0.85

Tested by

no test coverage detected