九度OJ题目1036:Old Bill
来源:互联网 发布:普通话练习软件 编辑:程序博客网 时间:2024/05/17 03:29
- 题目描述:
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.
- 样例输入:
726 7 952 3 7780 0 5
- 样例输出:
3 2 5119 5 184750
- 来源:
- 2007年上海交通大学计算机研究生机试真题
- 答疑:
解题遇到问题?分享解题心得?讨论本题请访问:http://t.jobdu.com/thread-7760-1-1.html
#include <cstdio>int main(){ int n; while(~scanf("%d",&n)){ int x,y,z; scanf("%d%d%d",&x,&y,&z); int ok=0; for(int a=9;a>=1;a--){ for(int b=9;b>=0;b--){ int t=10000*a+1000*x+100*y+10*z+b; if(t%n==0){ ok=1; printf("%d %d %d\n",a,b,t/n); break; } } if(ok) break; } if(!ok) 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 (模拟)
- 题目1036 Old Bill 九度Online Judge
- 题目1036:Old Bill
- 题目1036:Old Bill
- 题目1036:Old Bill
- 题目1036:Old Bill
- 题目1036:Old Bill
- 九度OnlineJudge之1036:Old Bill
- 九度OJ 1036:Old Bill (老比尔) (基础题)
- old bill
- 九度OJ 题目1029
- 九度OJ 题目1018
- iOS Block传值~demo
- hadoop shell命令详解
- 支付宝芝麻认证接口-扫码方式(芝麻认证接口与之类似)
- 生产者和消费者问题
- C#设计模式(4)——抽象工厂模式
- 九度OJ题目1036:Old Bill
- APPLY运算符
- Android Study Material Design 二 之:这可能是RecyclerView最全解析 初级使用(一)
- C#设计模式(5)——建造者模式(Builder Pattern)
- 抽象类
- 学习笔记-LVS的三种模式以及优缺点
- JavaSE-RxJava2笔记
- C#设计模式(6)——原型模式(Prototype Pattern)
- 《敦刻尔克》与《比利林恩的中场战事》——与战争中的人感同身受