九度OJ 1036:Old Bill (老比尔) (基础题)
时间限制:1 秒
内存限制:32 兆
特殊判题:否
提交:2691
解决:1432
- 题目描述:
-
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 <stdio.h> #define N 100 int main(void)
{
int n, i, j, num;
int x, y, z, xyz0; while (scanf("%d", &n) != EOF)
{
scanf("%d%d%d", &x, &y ,&z);
xyz0 = x*1000 + y*100 +z*10; int find = 0;
for (i=9; i>0; i--)
{
for (j=9; j>=0; j--)
{
num = i*10000 + xyz0 + j;
if (num % n == 0)
{
printf("%d %d %d\n", i, j, num/n);
find = 1;
break;
}
}
if (find == 1)
break;
}
if (find == 0)
printf("0\n");
} return 0;
}
/**************************************************************
Problem: 1036
User: liangrx06
Language: C
Result: Accepted
Time:0 ms
Memory:912 kb
****************************************************************/
九度OJ 1036:Old Bill (老比尔) (基础题)的更多相关文章
- 九度OJ 1261:寻找峰值点 (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:500 解决:37 题目描述: 给定一个整数序列,该整数序列存在着这几种可能:先递增后递减.先递减后递增.全递减.全递增. 请找出那个最大值的 ...
- 九度OJ 1158:买房子 (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:1801 解决:1096 题目描述: 某程序员开始工作,年薪N万,他希望在中关村公馆买一套60平米的房子,现在价格是200万,假设房子价格以每 ...
- 九度OJ 1083:特殊乘法 (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4114 解决:2809 题目描述: 写个算法,对2个小于1000000000的输入,求结果. 特殊乘法举例:123 * 45 = 1*4 + ...
- 九度OJ 1065:输出梯形 (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:5379 解决:2939 题目描述: 输入一个高度h,输出一个高为h,上底边为h的梯形. 输入: 一个整数h(1<=h<=1000 ...
- 九度OJ 1064:反序数 (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3758 解决:2773 题目描述: 设N是一个四位数,它的9倍恰好是其反序数(例如:1234的反序数是4321) 求N的值 输入: 程序无任 ...
- 九度OJ 1063:整数和 (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3456 解决:2254 题目描述: 编写程序,读入一个整数N. 若N为非负数,则计算N到2N之间的整数和: 若N为一个负数,则求2N到N之间 ...
- 九度OJ 1062:分段函数 (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3306 解决:1952 题目描述: 编写程序,计算下列分段函数y=f(x)的值. y=-x+2.5; 0<=x<2 y=2-1. ...
- 九度OJ 1052:找x (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:7335 解决:3801 题目描述: 输入一个数n,然后输入n个数值各不相同,再输入一个值x,输出这个值在这个数组中的下标(从0开始,若不在数 ...
- 九度OJ 1046:求最大值 (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:9861 解决:4013 题目描述: 输入10个数,要求输出其中的最大值. 输入: 测试数据有多组,每组10个数. 输出: 对于每组输入,请输 ...
- 九度OJ 1031:xxx定律 (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:6058 解决:3816 题目描述: 对于一个数n,如果是偶数,就把n砍掉一半:如果是奇数,把n变成 3*n+ 1后砍掉一半,直到该数 ...
随机推荐
- Topcoder SRM 145 DIV 1
Bonuses 模拟 题意:给你一个序列,按照百分比排序,再将百分比取整,再把剩余百分比加到最大的那几个. 题解:按照题意模拟就好.
- POJ 1961 Period KMP算法之next数组的应用
题意:给一个长度为n的字符串,如果它长度为l(2 <= l <= n)的前缀部分是由一些相同的字符串相接而成,输出前缀的长度l和长度为l时字符串重复的最大次数. 例如字符串为: aaaba ...
- luogu P1616 疯狂的采药
题目背景 此题为NOIP2005普及组第三题的疯狂版. 此题为纪念LiYuxiang而生. 题目描述 LiYuxiang是个天资聪颖的孩子,他的梦想是成为世界上最伟大的医师.为此,他想拜附近最有威望的 ...
- Loj #124. 除数函数求和
链接:https://loj.ac/problem/124 就是筛一下积性函数. #include<bits/stdc++.h> #define ll long long #define ...
- Nginx 初探
Nginx简介 Nginx(engine X)是一个开源.轻量级.高性能的HTTP和反向代理服务器,可以代理HTTP. IMAP/POP3/SMTP和TCP/UDP协议:其特点是占用内存少,并发能力强 ...
- php报错配置问题
在开发的时候php.ini ,要显示所有的错误 error_reporting=E_ALL | E_STRICT 在发布的时候可以显示除了notice之外的错误,打开错误记录功能 error_repo ...
- iframe 实现网页本页显示
<el-dialog title="" :visible.sync="dialogVisible"> <iframe src="ht ...
- CSS之BFC
BFC(Block Formatting Context,块格式上下文) 具有BFC特性的元素能够看作是隔离了的独立容器,容器里面的元素不会在布局上影响到外面的元素. 在CSS3中.BFC叫做Flow ...
- STL源代码剖析 容器 stl_vector.h
本文为senlie原创.转载请保留此地址:http://blog.csdn.net/zhengsenlie vector --------------------------------------- ...
- log4j email EmailDailyRollingFileAppender
log4j发送日志邮件, 纠正非网上流传的"达到 BufferSize KB就会发送邮件", 另外重写了一个发送邮件的类DailyRollingFileAppender. 用于定期 ...