The problem name is fctrl.
Here is my code.
#include
using namespace std;
int main() {
int t;
cin>>t;
long long exp=5;
long sum=0;
double sum2=0;
long long arr[t];
for(int i=0;i<t;i++)
{
cin>>arr[i];
}
for(int i=0;i<t;i++)
{
sum2=0;
exp=5;
while((double)(arr[i]/exp)>1)
{
sum=arr[i]/exp;
exp=exp*5;
sum2=sum2+sum;
}
cout<<sum2<<endl;
}
return 0;
}
I’m not getting ans in the 4th case
Input:
6
3
60
100
1024
23456
8735383
Output:
0
14
24
252
5860
2.18384e+06
Output should be:
0
14
24
253
5861
2183837
Keeping in mind, that you want to clarify about changing 2.18384e+06 to 2183837,
In the fourth case the answer should be 253 and mine is coming 252 then in the fifth it should be 5861 but my answer is 5860
FCTRL
#include
#include<bits/stdc++.h>
using namespace std;
int main() {
int t;
cin>>t;
long long exp=5;
long sum=0;
long long sum2=0;
long long arr[t];
for(int i=0;i<t;i++)
{
cin>>arr[i];
}
for(int i=0;i<t;i++)
{
sum2=0;
exp=5;
while((int)(arr[i]/exp)!=0)
{
sum=floor(arr[i]/exp);
exp=exp*5;
sum2=sum2+sum;
}
cout<<sum2<<endl;
}
return 0;
}
and my output is
0
14
24
253
5861
2183841
Ans is not coming in 6th case.
Quick tip -
Print 1/5,2/5,3/5,…100/5 . And check their value.