АВТ
Language:

Remote Training on Programming

Problems On-line status Contests FAQ
For authors:
Register  ||  Login
 
Hello, Guest! Login or register.

249. Power of number 2

Time Limit: 1 seconds
Memory Limit:1000KB
Points:5
View Problem Statistics Submit Problem added Undefined

Даны целые числа a (от 1 до 9) и b (от 1 до 1 млрд).

Требуется найти последние 6 цифр числа a в степени b (если в результате меньше 6 цифр, вывести его целиком).

Input

Два числа a и b, разделенные пробелом.

Output

Последние 6 цифр числа ab.

Sample

InputOutput
7 8764801

Hint 1

a^b = sqr(ab/2) при b - четном.

a^b = sqr(ab/2)*a при b - нечетном.

Hint 2

Последние 6 цифр числа - это остаток от деления на 1000000. Операцию взятия остатка можно применять после каждого умножения - результат от этого не изменится.


View Problem Statistics Submit Author/source:
Educational Courses / Data Structures and Algorithms / Data Structures /
695. I - Near Numbers 249. 243. Trees 251. КЛП->ЛКП 252. ЛКП->КЛП
We can all benefit by doing occasional "toy" programs, when artificial restrictions are set up, so that we are forced to push our abilities to the limit. The art of tackling miniproblems with all our energy will sharpen our talents for the real problems. Donald E. Knuth.
time generating 0.421 sec.
© Copyright VSTU, AVT, Nosov D.A.