当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3531:Alternating Sum of Digits

题目描述

Any integer number can be written as a sequence of digits in a specific system of base. For example, 5 in decimal based system can be written as 101 in binary based system. By writting down every number from 1 to N in system of base K one by one, we obtain a long sequence of digits. Your task is to calculate the alternating sum of digits, i.e. the difference between the sum of digits with odd index in the sequence and the sum of ones with even index.

For example, the sequence is 11011100101 and the alternating sum is 1 (the result of +1-1+0-1+1-1+0-0+1-0+1) given K = 2 and N = 101.

输入解释
K (1 < K ≤ 10) and N ( ≤ 1020, in the system of base K)
输出解释
The alternating sum. You should print it in decimal based system.
输入样例
2 101
输出样例
1
提示
It is safe to use 64-bit signed integral arithmetic.

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3531

最后修改于 2020-10-29T07:03:51+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 131072