九度OJ 1036:Old Bill
2018-03-04 15:26
483 查看
题目描述: 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.样例输入:
火鸡的总价格中间三位已知x,y,z,最高位不为零。要买的火鸡总数为n且火鸡单价为整数。输出一组最高位和最低位的值,要求火鸡单价最高。
#include<stdio.h>
#include<string.h>
int main() {
int n,x,y,z,flag=0;
while(~scanf("%d%d%d%d",&n,&x,&y,&z)){
flag=0;
for(int i=9; i>=1; i--) {
for(int j=9; j>=0; j--) {
int tmp=i*10000+x*1000+y*100+z*10+j;
if(tmp%n==0) {
printf("%d %d %d\n",i,j,tmp/n);flag=1;
break;
}
}
if(flag==1)
break;
}
if(!flag)
{
printf("0\n");
}
}
return 0;
}
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思路:
火鸡的总价格中间三位已知x,y,z,最高位不为零。要买的火鸡总数为n且火鸡单价为整数。输出一组最高位和最低位的值,要求火鸡单价最高。
#include<stdio.h>
#include<string.h>
int main() {
int n,x,y,z,flag=0;
while(~scanf("%d%d%d%d",&n,&x,&y,&z)){
flag=0;
for(int i=9; i>=1; i--) {
for(int j=9; j>=0; j--) {
int tmp=i*10000+x*1000+y*100+z*10+j;
if(tmp%n==0) {
printf("%d %d %d\n",i,j,tmp/n);flag=1;
break;
}
}
if(flag==1)
break;
}
if(!flag)
{
printf("0\n");
}
}
return 0;
}
相关文章推荐
- 九度OJ题目1036:Old Bill
- 九度OJ-1036:Old Bill
- 九度OJ 1036:Old Bill (老比尔) (基础题)
- 九度oj-1036-old bill
- 九度OJ 1036:Old Bill (老比尔) (基础题)
- 九度OJ题目1036:Old Bill
- 九度OJ 1036:Old Bill
- 九度OJ 1036 Old Bill (模拟)
- 【九度OJ】1036【模拟】
- 九度OJ 题目1067:n的阶乘
- 九度OJ 题目1141:Financial Management
- 九度OJ 1345:XXX定律之画X (递归)
- 数制转换 (九度oj题目44)
- 九度 oj 题目1082:代理服务器
- 九度 oj 题目1154:Jungle Roads
- 九度OJ-1172-哈夫曼树
- 九度OJ 1035找出直系亲属
- 九度oj-1085-求root(N,k)
- 九度OJ-1207:质因数的个数
- 九度oj1051数字阶梯求和