九度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,如果有多对数字的和等于 ...
随机推荐
- Hadoop--Unable to load native-hadoop library for your platform... using builtin-java classes where applicable Starting namenodes on [localhost]
Unable to load native-hadoop library for your platform... using builtin-java classes where applicabl ...
- 关于RabbitMQ服务器整合(二)
准备工作 15min IDEA maven 3.0 在开始构建项目之前,机器需要安装rabbitmq,你可以去官网下载,http://www.rabbitmq.com/download.html ,如 ...
- Java自动装箱中的缓存原理
今天看到一道'经典'面试题: Integer a = 100; Integer b = 100; System.out.println(a==b); Integer a2 = 200; Integer ...
- ubuntu启用root登陆
ubuntu系统不能够默认以root用户登陆系统如果你为了方便开发想每次登陆的时候以root用户登陆那么需要手动的做写更改打开终端 首先输入命令 sudo passwd root更新你的密码然后输入 ...
- java this的用法
this 含义:代表当前对象 用法: 用于返回对象的引用 示例代码 public class Test { public Test f() { return this;//获取当前对象的引用 } pu ...
- Unity运行错误代码处理
1.Unity在运行时出现如图错误,但不影响运行效果展示. 2.错误原因:代码不规范. 3.检查代码,查看变量是否定义正确.
- servlet之中文乱码:request.getParameter()
参考: http://blog.csdn.net/u014558484/article/details/53445178
- nginx:在linux上进行nginx的安装
-----1.安装 换源 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup 下载: wget ...
- Java:多个文档合并输出到一个文档
多个文档合并输出到一个文档 方法:Java NIO package First; import java.io.File; import java.io.FileInputStream; import ...
- information_schema
views 视图表,查看当前数据库有哪些视图 select table_catalog,table_schema,table_name,is_updatable,definer,security_ty ...