QOJ.ac

QOJ

実行時間制限: 5.0 s メモリ制限: 512 MB 満点: 100 ハック可能 ✓

#15545. Mathlab

統計

函数 $f(x)$ 定义为 $x$ 在十六进制表示下的所有数位之和。给定一个 $n$ 位的十六进制数 $x$ 和一个指数 $k$,计算:

$$ \sum_{i=0}^{x-1} f((16^k - 1) \cdot i) \bmod 2^{64} $$

输入格式

第一行包含两个正整数 $n$ 和 $k$($1 \le k \le n \le 100$ 且 $5k \ge n$)。

第二行包含一个长度为 $n$ 的字符串 —— 给定的十六进制数 $x$ 的值。

该字符串仅由十进制数字和字符 'A'、'B'、'C'、'D'、'E'、'F' 组成。此外,首位数字不为 '0'。

输出格式

唯一的一行包含一个整数 —— 答案。

样例

输入 1

4 1
7FFF

输出 1

1081320

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.