P27825 [洛谷] [Information and Future 2018] Integer Power
普及+
题目描述

Problem Description

Define the $n$-th power of $a$ as $a^n = a \times a \times \cdots \times a$ (with $n$ $a$'s multiplied together). Let $A$ be the number of odd digits (Arabic numerals $1, 3, 5, 7, 9$) in the decimal representation of $a^n$ when converted to a string, and $B$ be the number of even digits (Arabic numerals $0, 2, 4, 6, 8$). Compute the value of $A - B$.

For example, given $a = 3$ and $n = 12$, $a^n = 3^{12} = (531441)_{10}$.

Odd digits are highlighted: $\boxed{5}\boxed{3}\boxed{1}44\boxed{1}$, hence $A = 4$;

Even digits are highlighted: $531\boxed{4}\boxed{4}1$, hence $B = 2$, and $A - B = 2$.

Input Format

Input consists of two integers $a$ and $n$ on a single line.

Output Format

Output a single integer representing the value of $A - B$.

Sample Input and Output

Sample Input #1

3 12

Sample Output #1

2

Sample Input #2

5 18

Sample Output #2

-1

Notes

Sample 2 Explanation

$5^{18} = 3814697265625$, $A - B = -1$.

Data Size

$30\%$ of the data satisfies $a^n < 2^{32}$;

All data satisfies $2 \leq a \leq 9$, $1 \leq n \leq 100$.

This problem originally had a full score of $20\text{pts}$.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 12
样例输出
2