九度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,如果有多对数字的和等于 ...
随机推荐
- 牛客网第一场 A Monotonic Matrix
链接:https://www.nowcoder.com/acm/contest/139/A来源:牛客网 Count the number of n x m matrices A satisfying ...
- ORM框架之SQLALchemy
一.面向对象应用场景: 1.函数有共同参数,解决参数不断重用: 2.模板(约束同一类事物的,属性和行为) 3.函数编程和面向对象区别: 面向对象:数据和逻辑组合在一起:函数编程:数据和逻辑不能组合在一 ...
- Kali配置教程
1.配置软件源 所有操作没有说明,都是以root身份执行. 打开一个终端执行: cat >> /etc/apt/sources.list <<EOF deb http://mi ...
- java 常用命令
#查看堆使用情况jmap -heap [pid]#查看占用内存高的对象jmap -histo:live [pid] | head -n 100#查看占用内存高的对象,dump成文件,线下分析jmap ...
- activity和fragment之前运行的生命周期
1.activity生命周期 2.fragment的生命周期 3.对比图 4.测试代码 package com.goso.testapp; import android.app.Activity; i ...
- Java Web(四) 过滤器Filter
Filter概述 Filter意为滤镜或者过滤器,用于在Servlet之外对request或者response进行修改.Filter提出了过滤链的概念.一个FilterChain包括多个Filter. ...
- 在引用的laravel的@include子模板中传递参数
调用传参: @include("message",['msg'=>'中国']) 在message子模板中调用msg的值: {{msg}}
- 基于Redis+MySQL+MongoDB存储架构应用
摘 要: Redis+MySQL+MongoDB技术架构实现了本项目中大数据存储和实时云计算的需求.使用MongoDB切片的水平动态添加,可在不中断平台业务系统的同时保障扩容后的查询速度和云计算效能 ...
- Linux系统默默改变了人类世界的生活方式
你知道操作系统都有些什么吗?Windows啊.这是我在上大学之前的问答,我当时认为只一种叫做Windows的操作系统,可是我错了,当我上大学以后,作为计算机专业的一名学生的时候我第一次接触到了除Win ...
- 利用include动作实现参数传递
<%--程序string.jsp--%> <%@ page language="java" import="java.util.*" page ...