Advertisement
Guest User

CODd

a guest
Nov 22nd, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int main()
  5. {
  6. long long n,x,i,prod=1,nr2=0,nr5=0;
  7. cin>>n;
  8. for(i=1;i<=n;++i)
  9. {
  10. cin>>x;
  11. while(x%2==0)
  12. {
  13. x/=2;
  14. ++nr2;
  15. }
  16. while(x%5==0)
  17. {
  18. x/=5;
  19. ++nr5;
  20. }
  21. prod=(prod*(x%10))%10;
  22. }
  23. if(nr2>nr5)
  24. {
  25. for(i=nr5;i<nr2;++i)
  26. {
  27. prod*=2;
  28. }
  29. }
  30. else
  31. {
  32. for(i=nr2;i<nr5;++i)
  33. {
  34. prod*=5;
  35. }
  36. }
  37. cout<<prod%10;
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement