confusion with modulo

Правка en2, от PROGRAMMAR, 2017-07-09 00:09:17

long long ans=1;

for(int i=1; i<=20000000; i++)

{

ans*=i;

while(ans%10==0)

ans/=10;

ans%=100000000000LL;

}

cout<<ans%10<<endl;

#### This is a code of finding the last-non-zero-digit of 20000000! my question why & how 100000000000(10^11) is safe as modulo? shouldn't it be at least 10^15? since 19999998 * 19999999 = 399999940000002 which is greater than 10^11 please clear it to me. Thanks in advance.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский PROGRAMMAR 2017-07-09 00:11:50 43
en2 Английский PROGRAMMAR 2017-07-09 00:09:17 50
en1 Английский PROGRAMMAR 2017-07-09 00:06:57 453 Initial revision (published)