描述
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.
示例1

输入:
72
6 7 9
5
2 3 7
78
0 0 5
输出:
3 2 511
9 5 18475
0

题目大意:
N只火鸡的价格为$_XYZ_,火鸡的总数N在1到99之间。价格由五位数组成,两边的数字由于褪色而看不清,所以只能看到中间的三位数。假设第一个数字非零,每只火鸡的价格是整数,并且所有火鸡的价格相同。给定N,X,Y和Z,编写一个程序来猜测两边褪色的数字和火鸡的原始价格。如果多个价格符合题意,那么输出最昂贵的那个。
知识点: 暴力求解 枚举
AC代码:

#include<bits/stdc++.h>using namespace std;int main()
{int n;int x, y, z;int sum;int a, b;while(cin >> n) // 多样例输入注意用while循环输入{cin >> x >> y >> z;int flag = 0;for(int i = 9; i > 0; i--) // 做减循环,得到最贵的就可以跳出{for(int j = 9; j >= 0; j--){sum = i * 10000 + x * 1000 + y * 100 + z * 10 + j;if(sum % n == 0){cout << i << ' ' << j << ' ' << sum / n << endl;flag = 1;break; //跳出内层循环}}if(flag){break; // 跳出外层循环}}if(flag == 0) // 注意:找不到结果时,输出0{cout << 0 << endl;}}return 0;
}

KY95 Old Bill相关推荐

  1. [分享] 从定制Win7母盘到封装详细教程 By BILL ( 10月23日补充说明 )

    [分享] 从定制Win7母盘到封装详细教程 By BILL ( 10月23日补充说明 ) billcheung 发表于 2011-10-23 00:07:49 https://www.itsk.com ...

  2. 人工智能和自然智能能否交汇?李飞飞对话斯坦福神经生物学教授Bill Newsome

    作者:SHANA LYNCH 机器之心编译 编辑:张倩 计算在神经科学中扮演了什么角色?在分子水平上理解大脑能否带来更好的神经网络?人工智能和自然智能之间是否存在一道无法逾越的鸿沟?会不会出现一个研究 ...

  3. 十年——透过BILL的眼睛

    总算匆匆忙忙的有了一个停顿,回家了.回家那2000多公里的路上我一直在翻那本已经旧得发黄的书.这本书的中文译名叫<未来之路>.当然,这不是什么科幻小说,也不是政治家的"五年计划& ...

  4. [BZOJ 1879][SDOI 2009]Bill的挑战 题解(状压DP)

    [BZOJ 1879][SDOI 2009]Bill的挑战 Description Solution 1.考虑状压的方式. 方案1:如果我们把每一个字符串压起来,用一个布尔数组表示与每一个字母的匹配关 ...

  5. YTU 2887: D--机器人Bill

    2887: D--机器人Bill 时间限制: 1 Sec  内存限制: 128 MB 提交: 112  解决: 22 题目描述 最近,Dr. Jiang 新设计一个机器人Bill.Bill很聪明,会做 ...

  6. Teradata首席分析官Bill Franks:数据分析变革犹如一场工业革命

    2013年Teradata天睿公司首席分析官Bill Franks出版了<驾驭大数据>,时隔两年他又带来了新书<数据分析变革>,从书名可以看出大数据的应用已经发生了质变.Bil ...

  7. bzoj千题计划207:bzoj1879: [Sdoi2009]Bill的挑战

    http://www.lydsy.com/JudgeOnline/problem.php?id=1879 f[i][j] 表示匹配了i个字符,匹配字符串的状态为j的方案数 枚举下一个字符是什么 计算加 ...

  8. P2167 [SDOI2009]Bill的挑战

    P2167 [SDOI2009]Bill的挑战 题意: 有n个长度一样的字符串,字符串的每一位是?或者确定的字母,,求与这 N 个串中的刚好 K 个串匹配的字符串 T 的个数 1<=N<= ...

  9. SDOI 2009 BIll的挑战

    题目描述 Description Sheng bill不仅有惊人的心算能力,还可以轻松地完成各种统计.在昨天的比赛中,你凭借优秀的程序与他打成了平局,这导致Sheng bill极度的不满.于是他再次挑 ...

最新文章

  1. Linux运维工程师的十个基本技能点
  2. SAP 产品一脉相承的 UI 增强思路,在 SAP Commerce Cloud(电商云) UI 增强实现中的体现
  3. mybatis java8_Java 8 开发的 Mybatis 注解代码生成工具
  4. HTML,,,音乐,html embed用法
  5. 最大尺寸分辨率_未来就在眼前!全球最大尺寸、最高分辨率硅基OLED显示屏在肥点亮...
  6. Android动画定义知识小结
  7. 《Python程序设计开发宝典》第一波转发积攒活动中奖名单
  8. python 字符串的(乘法和in)(一分钟读懂)
  9. @property 的属性class
  10. 解决 Beyond Compare 3 许可证密钥被撤销
  11. python爬取大众点评字体_python采集大众点评(字体反爬)
  12. python自带的pip版本过低 卸载pip重写安装V10
  13. MySQL数据库中库、表名、字段的大小写问题
  14. 三、SpringSecurity 动态权限访问控制
  15. Spring batch教程 之 读取CSV文件并写入MySQL数据库
  16. python中必须要会的四大高级数据类型(字符,元组,列表,字典)
  17. gaussDB 安装使用
  18. 社区计算机义务维修策划书,义务维修电脑策划书.doc
  19. 倍福控制第三方伺服走CSV模式--以汇川伺服为例
  20. “我才是腾讯的第一任董事长”

热门文章

  1. C语言数据结构【手抄版】第三章 栈和队列
  2. 金九银十,入职字节跳动那一天,我哭了
  3. C++利用二维数组求解线性方程组
  4. 【Java】可变参数
  5. day05_日常SQL练习(二)
  6. java float小数点后几位小数_java实现double数据保留小数点后几位
  7. 【Matlab 图像处理】图像平滑系统GUI
  8. MySQL之查看数据库(SHOW DATABASES语句)
  9. javascript百炼成仙 第一章1.10 对象内容的遍历
  10. 计算机保研er 8月应该做什么?