P27897 [洛谷] [Language Monthly Contest 202312] NK
普及-
题目描述

Problem Description

Given two positive integers \( N, K \), please count the number of positive integers \( x \) that meet the following conditions:

  • \( 1 \leq x \leq N ^ N \).
  • \( (x \bmod K) \) is a multiple of \( N \).
  • The last digit of \( x \) is \( N \).

\( x \bmod K \) represents the remainder of \( x \) divided by \( K \), for example, \( 7 \bmod 3 = 1 \).

Input Format

Input consists of two integers \( N, K \) on a single line.

Output Format

Output a single integer, which is the count of \( x \) that meets all the conditions specified in the problem.

Sample Input and Output

Sample Input #1

4 6

Sample Output #1

17

Sample Input #2

7 6

Sample Output #2

0

Notes/Hints

Data Size and Constraints

  • For \( 30\% \) of the test cases, \( 1 \leq N, K \leq 6 \).
  • For \( 100\% \) of the test cases, \( 1 \leq N \leq 9 \), \( 1 \leq K \leq 10 ^ 6 \).
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
4 6
样例输出
17