-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathna2a_and_lucky_stone.c
67 lines (67 loc) · 939 Bytes
/
na2a_and_lucky_stone.c
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
63
64
65
66
67
#include<stdio.h>
#include<math.h>
int main()
{
long long int i,n,z,count5,count2,count4;
long long int p,a[100000];
scanf("%lld", &n);
for(i=0;i<n;i++)
{
scanf("%lld", &a[i]);
p=a[i];
count2=0;
count5=0;
count4=0;
if(p%5==0)
{
while(p%5==0)
{
p=p/5;
count5++;
}
p=a[i];
while(p%2==0)
{
p=p/2;
count2++;
}
if((count2==0)&&(count5>0))
{
if(count5%2==0)
{
count4=count5/2;
z=pow(4,count4);
a[i]=a[i]*z;
}
else
{
count4=count5/2+1;
z=pow(4,count4);
a[i]=a[i]*z;
}
}
if((count2>0)&&(count5>0))
{
if(count5>=count2)
count5=count5-count2;
else
count5=0;
if(count5%2==0)
{
count4=count5/2;
z=pow(4,count4);
a[i]=a[i]*z;
}
else
{
count4=count5/2+1;
z=pow(4,count4);
a[i]=a[i]*z;
}
}
}
}
for(i=0;i<n;i++)
printf("%lld\n", a[i]);
return 0;
}