Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- long long n,x,i,prod=1,nr2=0,nr5=0;
- cin>>n;
- for(i=1;i<=n;++i)
- {
- cin>>x;
- while(x%2==0)
- {
- x/=2;
- ++nr2;
- }
- while(x%5==0)
- {
- x/=5;
- ++nr5;
- }
- prod=(prod*(x%10))%10;
- }
- if(nr2>nr5)
- {
- for(i=nr5;i<nr2;++i)
- {
- prod*=2;
- }
- }
- else
- {
- for(i=nr2;i<nr5;++i)
- {
- prod*=5;
- }
- }
- cout<<prod%10;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement