Problemele de pe pbinfo Zerouri(360) FactZero(439) si Divizorii impari(2697)
Maca una
Răspunsuri la întrebare
//FactZero
//439
#include <iostream>
using namespace std;
int n,i,nr,x;
int main()
{
cin>>n;
for(i=5;i<=n;i+=5)
{
x=i;
while((x%5)==0)
{
nr+=1;
x/=5;
}
}
cout<<nr<<endl;
return 0;
}
Zerouri ------------------------------------------------------
#include <iostream>
using namespace std;
int main()
{
long long n, i, exp2=0, exp5=0, num, nrz;
cin >> n;
for (i=1; i<=n; ++i)
{
cin >> num;
while (num%2==0)
{
++exp2;
num/=2;
}
while (num%5==0)
{
++exp5;
num/=5;
}
}
nrz=min(exp2,exp5);
cout << nrz;
return 0;
}
problema DivizoriImpari ----------------
#include <iostream>
using namespace std;
long long divMaxImpar(long long num)
{
while (num%2==0)
num/=2;
return num;
}
int main()
{
long long n, i, num;
cin >> n;
for (i=1; i<=n; ++i)
{
cin >> num;
cout << divMaxImpar(num) << " ";
}
return 0;
}