1036.Old Bill
来源:互联网 发布:神玥软件招聘 编辑:程序博客网 时间:2024/06/05 19:27
题目描述:
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.
输入:
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_.
输出:
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
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.
输入:
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_.
输出:
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
#include <iostream>using namespace std;int main(){int N, X, Y, Z;while (cin >> N >> X >> Y >> Z){bool flag = false;for (int i = 9; i > 0; --i){if (!flag) //判断是否应该执行第二个循环{for (int j = 9; j >= 0; --j){int sum = i * 10000 + X * 1000 + Y * 100 + Z * 10 + j;if (sum % N == 0){cout << i << " " << j << " " << sum / N << endl;flag = true;break; //找到之后直接跳出第二个循环,剩下的循环不执行。}}}}if (flag == false)cout << 0 << endl;}return 0;}
0 0
- 1036.Old Bill
- old bill
- zoj 2679 Old Bill
- zoj 2679 Old Bill
- 题目1036:Old Bill
- 题目1036:Old Bill
- 题目1036:Old Bill
- 题目1036:Old Bill
- 题目1036:Old Bill
- Solution of ZOJ 2679 Old Bill
- ZOJ 2679 Old Bill(STL应用)
- 九度OnlineJudge之1036:Old Bill
- ZOJ 2679 Old Bill(数学题)
- ZOJ Problem Set - 2679 Old Bill
- 九度OJ题目1036:Old Bill
- 九度oj-1036-Old Bill
- 九度OJ-1036:Old Bill
- 九度oj-1036-old bill
- HDU DP28题
- POJ 1018 Communication System (动态规划)
- What is the study?
- 不错的优秀博客收集
- ACdream区域赛指导赛之专题赛系列(1)の数学专场
- 1036.Old Bill
- sql学习笔记(MySQL)
- ACM各类题集
- Java - NIO之Buffer(下)
- 数据结构教程 第八课 线性表的链式表示与实现
- 数据结构教程 第六课 线性表的顺序表示和实现
- 机器学习方法
- 浅谈Hibernate3中的事务
- hFmIdc顺蛋ARSBU