题目1036:Old Bill

时间限制:1 秒

内存限制:32 兆

特殊判题:

提交:3748

解决:2053

题目描述:

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
来源:
2007年上海交通大学计算机研究生机试真题
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <ctype.h> using namespace std; int main() {
int n, x, y, z;
while(scanf("%d", &n) != EOF) {
scanf("%d%d%d", &x, &y, &z);
int sa, sb, per = ;
for(int a = ; a <= ; a++) {
for(int b = ; b <= ; b++) {
int m = a*+x*+y*+z*+b;
int re = m % n;
int tem = m / n;
if(re == && tem > per) {
per = tem;
sa = a; sb = b;
}
}
}
if(per != ) {
printf("%d %d %d\n", sa, sb, per);
}
else{
printf("%d\n", per);
} } return ;
}

注意观察题目给出样例最后一个是0,证明单价为0的时候不要输出总价的开头和结尾

这个题目没有说明,但是自己要注意看

九度OJ1036-空缺数字计算-暴力破解的更多相关文章

  1. 九度OJ 1010:计算A+B【字符串和数组】

    /*======================================================================== 题目1010:A + B 时间限制:1 秒内存限制 ...

  2. 九度OJ 1544 数字序列区间最小值

    题目地址:http://ac.jobdu.com/problem.php?pid=1544 题目描述: 给定一个数字序列,查询任意给定区间内数字的最小值. 输入: 输入包含多组测试用例,每组测试用例的 ...

  3. 九度OJ 1349 数字在排序数组中出现的次数 -- 二分查找

    题目地址:http://ac.jobdu.com/problem.php?pid=1349 题目描述: 统计一个数字在排序数组中出现的次数. 输入: 每个测试案例包括两行: 第一行有1个整数n,表示数 ...

  4. 九度OJ 1101:计算表达式 (DP)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4340 解决:1335 题目描述: 对于一个不存在括号的表达式进行计算 输入: 存在多种数据,每组数据一行,表达式不存在空格 输出: 输出结 ...

  5. 九度oj 1349 数字在排序数组中出现的次数

    原题链接:http://ac.jobdu.com/problem.php?pid=1349 二分.. #include<algorithm> #include<iostream> ...

  6. 九度OJ,题目1089:数字反转

    题目描述: 12翻一下是21,34翻一下是43,12+34是46,46翻一下是64,现在又任意两个正整数,问他们两个数反转的和是否等于两个数的和的反转. 输入: 第一行一个正整数表示测试数据的个数n. ...

  7. [转帖]利用hydra(九头蛇)暴力破解内网windows登录密码

    利用hydra(九头蛇)暴力破解内网windows登录密码 https://blog.csdn.net/weixin_37361758/article/details/77939070 尝试了下 能够 ...

  8. hydra(九头蛇)多协议暴力破解工具

    一.简介 hydra(九头蛇)全能暴力破解工具,是一款全能的暴力破解工具,使用方法简单 二.使用 使用hydra -h 查看基本用法 三.命令 hydra [[[-l LOGIN|-L FILE] [ ...

  9. 剑指Offer - 九度1352 - 和为S的两个数字

    剑指Offer - 九度1352 - 和为S的两个数字2014-02-05 18:15 题目描述: 输入一个递增排序的数组和一个数字S,在数组中查找两个数,是的他们的和正好是S,如果有多对数字的和等于 ...

随机推荐

  1. 64位Ubuntu下配置CP-ABE环境

    CP-ABE环境配置 本文密码学专业,论文仿真需要CP-ABE,现将配置过程作个记录 cpabe依赖pbc,pbc依赖gmp,gmp依赖M4.bison.flex,所以.. sudo apt-get  ...

  2. JavaScript 上万条数据 导出Excel文件(改装版)

    最近项目要js实现将数据导出excel文件,网上很多插件实现~~那个开心呀,谁知道后面数据量达到上万条时出问题:浏览器不仅卡死,导出的excel文件一直提示网络失败.... debug调试发现var  ...

  3. weblogic启动比一般机器慢原因

    weblogic启动慢一般先看setDomainEnv.sh中分配给JVM的内存大小,如果分配足够(没部应用一般也要1G以上)那么再用free -g看本机剩余内存是否充足.如果都没问题还是比一般机器启 ...

  4. Java类型中ParameterizedType,GenericArrayType,TypeVariabl,WildcardType详解

    (1). 和反射+泛型有关的接口类型 java.lang.reflect.Type:java语言中所有类型的公共父接口 java.lang.reflect.ParameterizedType java ...

  5. QWebView崩溃的问题

    http://www.cnblogs.com/kobe-echo/p/5720765.html#undefined

  6. laravel中判断当前页面与连接地址是否一致,并添加效果:

  7. 中国队再创佳绩,IOI2018喜获四金

    第30届国际信息学奥林匹克竞赛(IOI2018)于9月1日-8日在日本筑波举行,共有来自87个国家(地区)的335名选手参赛.    中国代表队四名选手经过努力拼搏,获得金牌.其中,杨懋龙(湖南长沙市 ...

  8. c语言中printf("%x",-1);为什么会输出-1的十六进制补码??

    计算机存储的时候是以补码的形式存进去的,输出来在以你原码的形式输出(这个形式就是你设置的形式)! 比如: -1 (32位模式) 存: 1 000000000000000000000000000000 ...

  9. 单元测试模拟-moq

    1.moq 支持 net core 2.moq 通过一个接口类型 可以产生一个新的类 3.举例 //define interface to be mocked public interface ITe ...

  10. ROS tab键补全操作出现错误

    ros tab键补全操作出现错误如下: $ roslaunch sp[rospack] Warning: error while crawling /home/hemudu: boost::files ...