九度OJ1036-空缺数字计算-暴力破解
题目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-空缺数字计算-暴力破解的更多相关文章
- 九度OJ 1010:计算A+B【字符串和数组】
/*======================================================================== 题目1010:A + B 时间限制:1 秒内存限制 ...
- 九度OJ 1544 数字序列区间最小值
题目地址:http://ac.jobdu.com/problem.php?pid=1544 题目描述: 给定一个数字序列,查询任意给定区间内数字的最小值. 输入: 输入包含多组测试用例,每组测试用例的 ...
- 九度OJ 1349 数字在排序数组中出现的次数 -- 二分查找
题目地址:http://ac.jobdu.com/problem.php?pid=1349 题目描述: 统计一个数字在排序数组中出现的次数. 输入: 每个测试案例包括两行: 第一行有1个整数n,表示数 ...
- 九度OJ 1101:计算表达式 (DP)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4340 解决:1335 题目描述: 对于一个不存在括号的表达式进行计算 输入: 存在多种数据,每组数据一行,表达式不存在空格 输出: 输出结 ...
- 九度oj 1349 数字在排序数组中出现的次数
原题链接:http://ac.jobdu.com/problem.php?pid=1349 二分.. #include<algorithm> #include<iostream> ...
- 九度OJ,题目1089:数字反转
题目描述: 12翻一下是21,34翻一下是43,12+34是46,46翻一下是64,现在又任意两个正整数,问他们两个数反转的和是否等于两个数的和的反转. 输入: 第一行一个正整数表示测试数据的个数n. ...
- [转帖]利用hydra(九头蛇)暴力破解内网windows登录密码
利用hydra(九头蛇)暴力破解内网windows登录密码 https://blog.csdn.net/weixin_37361758/article/details/77939070 尝试了下 能够 ...
- hydra(九头蛇)多协议暴力破解工具
一.简介 hydra(九头蛇)全能暴力破解工具,是一款全能的暴力破解工具,使用方法简单 二.使用 使用hydra -h 查看基本用法 三.命令 hydra [[[-l LOGIN|-L FILE] [ ...
- 剑指Offer - 九度1352 - 和为S的两个数字
剑指Offer - 九度1352 - 和为S的两个数字2014-02-05 18:15 题目描述: 输入一个递增排序的数组和一个数字S,在数组中查找两个数,是的他们的和正好是S,如果有多对数字的和等于 ...
随机推荐
- 你还有没有印象?腾讯QQ16个版本界面你认识多少?
腾讯公司成立于1998年11月11日(马化腾也曾经戏称“腾讯公司的生日被马云弄成双11购物节了”).1997年,马化腾接触到了ICQ:1998年11月11日,马化腾和同学张志东在广东省深圳市注册成立“ ...
- telnet的装配及xinetd的讨论
telnet由于是不安全的明文传输所以基本被ssh取代了,尤其是在Linux上:不过还是可能会用到,且启停方式还有些不同所以还是有必要说明一下. rpm -qa | grep telnet #查看是否 ...
- 关于TCP长连接和发送心跳的一些理解
原因 TCP是一种有连接的协议,但是这个连接并不是指有一条实际的电路,而是一种虚拟的电路.TCP的建立连接和断开连接都是通过发送数据实现的,也就是我们常说的三次握手.四次挥手.TCP两端保存了一种数据 ...
- CentOS下安装MYSQL8.X并设置忽略大小写
安装 在官网上下载:mysql80-community-release-el7-2.noarch.rpm.安装方式与5.7基本相同.详细安装过程见:CentOS下安装mysql5.7和mysql8.x ...
- Linux下使用timedatectl命令时间时区操作详解
timedatectl命令对于RHEL / CentOS 7和基于Fedora 21+的分布式系统来说,是一个新工具,它作为systemd系统和服务管理器的一部分,代替旧的传统的用在基于Linux分布 ...
- Uva 11520 - Fill the Square 贪心 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- 枚举,Math和Random
1.实用类: 01.枚举 enum Student stu=new Student(); 我们为了保证用户一个健康的输入! 我们使用了封装特性! 用户就不能直接访问我们的属性了!! private c ...
- Java:将Excel数据导入到数据库(一眼就看会)
所用Jar包 1. sqljdbc4.jar 连接数据库的Jar包(根据数据库的不同进行选择,我用的SqlServer2008) 2.Jxl.jar 访问Excel的Jar包 注意:支持以.xls结尾 ...
- 深入理解java虚拟机---虚拟机工具VisualVM(十九)
性能分析神器VisualVM 9602 VisualVM 是一款免费的,集成了多个 JDK 命令行工具的可视化工具,它能为您提供强大的分析能力,对 Java 应用程序做性能分析和调优.这些功能包括生成 ...
- 虚拟机中扩展linux系统存储空间
reference: https://blog.csdn.net/greenapple_shan/article/details/52799631 https://blog.csdn.net/lyd1 ...