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

建议使用的浏览器:

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

4485:B-Casting

题目描述
Casting around for problems leads us to combine modular arithmetic with different integer bases, particularly the problem of computing values modulo b-1, where b is the base in which the value is represented. For example,

782910 mod 9 = 8,
377777777777777738 mod 7 = 6
1234567 mod 6 = 3

(Note that 377777777777777738 = 112589990684261910 and 1234567 = 2287510.)

Your job is to write a program that reads integer values in various bases and computes the remainder after dividing these values by one less than the input base.
输入解释
The first line of input contains a single integer P, (1 <= P <= 1000) , which is the number o data sets that follow. Each data set should be processed identically and independently.

Each data set consists of a single line of input containing three space-separated values. The first is an integer which is the data set number. The second is an integer which is the number, B (2 <= B <= 10), denoting a numeric base. The third is an unsigned number, D, in base B representation. For this problem, the number of numeric characters in D will be limited to 10,000,000.
输出解释
For each data set there is a single line of output. It contains the data set number followed by a single space which is then followed by the remainder resulting from dividing D by (B-1).
输入样例
4
1 10 7829
2 7 123456
3 6 432504023545112
4 8 37777777777777773 
输出样例
1 8
2 3
3 1
4 6
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

题目来源 Greater New York 2012

源链接: HDU-4485

最后修改于 2020-10-25T23:13:59+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
4000/2000MS(Java/Others) 32768/32768K(Java/Others)