1363.Old Bill

通过数:105提交数:252学校:上海交通大学考研机试真题 题目列表 标签
题目描述 Among grandfather’s papers a bill was found. $72$ turkeys $ 679 $ The first and the last digits of the number that obviously represented the total price of those turkeys are replaced here by blanks (denoted ), for they are faded and are illegible. What are the two faded digits and what was the price of one turkey? We want to write a program that solves a general version of the above problem. $N$ turkeys $ XYZ $ The total number of turkeys, $N$, is between $1$ and $99$, including both. The total price originally consisted of five digits, but we can see only the three digits in the middle. We assume that the first digit is nonzero, that the price of one turkeys is an integer number of dollars, and that all the turkeys cost the same price. Given $N$, $X$, $Y$, and $Z$, write a program that guesses the two faded digits and the original price. In case that there is more than one candidate for the original price, the output should be the most expensive one. That is, the program is to report the two faded digits and the maximum price per turkey for the turkeys. 翻译(原题无翻译): 在祖父的文件中发现了一张账单。 $72$ 只火鸡$ 679 $,显然代表这些火鸡的总价格的数字的第一个和最后一个数字在这里被空白代替(表示 ),因为它们已经褪色,难以辨认。 那两个褪色的数字是什么?一只火鸡的价格是多少?我们打算编写一个程序来解决一般情况下的上述问题。 $N$ 只火鸡$XYZ$,火鸡的总数 $N$ 介于 $1$ 和 $99$ 之间。 总价原本是五位数字,但我们只看到中间三位。 我们假设第一个数字是非零,一只火鸡的价格是美元的整数,所有火鸡的价格都是一样的。 给定 $N$, $X$, $Y$ 和 $Z$,编写一个程序来猜测这两个褪色的数字和原始价格。 如果有一个以上的候选原始价格,输出最昂贵的。 也就是说,该程序将报告这两个褪色的数字和每只火鸡的最高价格。 输入格式 The first line of the input file contains an integer $N$ ($0<N<100$), which represents the number of turkeys. In the following line, there are the three decimal digits $X$, $Y$, and $Z$, separated by a space, of the original price $ XYZ $. 翻译(原题无翻译): 输入的第一行包含一个整数 $N$ ($0<N<100$),代表火鸡的数量。 下一行是原始价格$ XYZ $的三位十进制数字 $X$、$Y$ 和 $Z$,用空格分隔。 输出格式 For each case, output the two faded digits and the maximum price per turkey for the turkeys. 对于每个样例,输出两个褪色数字和每只火鸡的最高价格。 输入样例 72 6 7 9 5 2 3 7 78 0 0 5 输出样例 3 2 511 9 5 18475 0
C
补全
点击调试按钮即可调试代码。

点击提交按钮即可提交代码。