C++版本:
对于每个数计算出可以最多分解成多少个2乘积,以及多少个5乘积,然后累计起来,最后输出2的个数和5的个数中的较小值,因为只有2*5会出现0.
int c1=0,c2=0;
for(int i=1;i<=10;i++)
for(int j=1;j<=10;j++)
{
int x;
int t=x;
cin>>x;
while(x%2==0)
{
c1++;
x=x/2;
}
while(t%5==0)
{
c2++;
t=t/5;
}
}
cout<<min(c1,c2);
Python版本:
当然是暴力计算
if __name__ == '__main__':
with open("in.txt", "r") as f:
ans = 1
for line in f:
list = line.split()
for i in list:
ans = ans * int(i)
print(ans)
if __name__ == '__main__':
ans = 1
for i in range(0, 10):
n = int(input())
ans *= n
print(ans)