-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp12.cpp
More file actions
62 lines (50 loc) · 1.23 KB
/
Copy pathp12.cpp
File metadata and controls
62 lines (50 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
Input First line of input contains an integer T number of test cases. Each test case contains an integer M (1 ≤ M ≤ 100,000) — the required number of trailing zeroes in factorial.
Output First print k — the number of values of n such that the factorial of n ends with m zeroes. Then print these k integers in increasing order.
i/p
1
1
o/P
5 6 7 8 9
*/
#include<iostream>
using namespace std;
int main(){
int T,m,temp;
cin>>T;
long long int num=1,f=24; //(4!)
long int next=5,count,test=0;
long long int a[100],pos=0;
while(T--)
{
cin>>m;
temp=m;
while(temp--)
num *=10;
do
{
f *= next++;
}while(f<num);
do
{
num = f;
count=0;
while(count<=m)
{
test = num%10;
num /=10;
if(!test)
++count;
else break;
}
if(count == m)
a[pos++] = next-1;
f*= next++;
} while(count<=m);
cout<<pos<<" "<<f<<endl;
for(int i=0;i<pos;i++)
cout<<a[i]<<" ";
cout<<endl;
num=1;next=5;f=24,test=0,pos=0;
}
}