题目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. MySQL中的文件

    查看数据目录: select @@datadir; 共享表空间: ibdata1 Redo log file:ib_logfile0, ib_logfile1 二进制日志:需要配置参数 server- ...

  2. 使用python操作hdfs,并grep想要的数据

    代码如下: import subprocess for day in range(24, 30): for h in range(0, 24): filename = "tls-metada ...

  3. Redis的JAVA连接

    ShardedJedis用法 package com.zhi.demo; import java.util.Arrays; import java.util.List; import redis.cl ...

  4. Chrome使用的plugin

    Chrome使用的plugin   翻译 google翻译 youlict划词翻译     书签   查询书签 neater bookmarks 博客园收藏网页 书签保存 bookmark sysnc ...

  5. io重定向打开关闭 Eclipse中c开发printf无法输出解决办法

    if(freopen("e:\\lstm-comparec\\lstm\\lstm\\output.txt","a",stdout)==NULL)fprintf ...

  6. 模块化&os&sys

    syspath python 使用import模块调用的优先级是根据sys.path路径来的,此变量中位置在列表中的先后顺序来调用,如果先找到对应的模块,则先调用此模块. import sys pri ...

  7. [BZOJ1588]营业额统计

    Problem 每次给你一个数,找出前面的数与这个数的差的绝对值的最小值 Solution Splay Notice 找不到前驱和后继时,会出错. Code #include<cmath> ...

  8. 一个canvas的demo

    该demo放于tomcat下运行,否则出现跨域错误 <!DOCTYPE html> <html> <head> <meta charset="utf ...

  9. 一些做vue前端的经验

    1.先赋值,后渲染 场景:表格渲染中,一般都是这样把json的东西传给table的 this.tableData = json.data.rows 然后的话我们一般会在渲染前对json中的数据做一些转 ...

  10. Factory,工厂设计模式,C++描述

    body, table{font-family: 微软雅黑; font-size: 13.5pt} table{border-collapse: collapse; border: solid gra ...