题目描述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
import java.io.*;
import java.util.*;
public class Main
{public static void main(String[] args){try {BufferedReader br= new BufferedReader(new InputStreamReader(System.in));String str;while((str=br.readLine()) != null){int nums = Integer.parseInt(str);String[] price = br.readLine().split(" ");int a = 0;int b = 0;int max = 0;for(int i = 1; i <= 9; i++) {for(int j = 0; j <= 9; j++) {int total = Integer.parseInt(i+price[0]+price[1]+price[2]+j);if(total%nums == 0) {a = i;b = j;max = total/nums;}}}if(max == 0) System.out.println("0"); else System.out.println(a+" "+b+" "+max);}} catch (IOException e) {e.printStackTrace();}}
}

上海交通大学 Old Bill(java)相关推荐

  1. Old Bill(上海交通大学复试上机题)

    Old Bill(上海交通大学复试上机题) 题目描述 Among grandfather's papers a bill was found. 72 turkeys $_679_The first a ...

  2. 半导体物理与器件_上海交通大学874半导体物理2班开课啦!

    上交874半导体物理和器件基础的试听课将在8月25号周二晚上7点开始,欢迎对上交微电子感兴趣的同学来听,也欢迎大家加入上海交通大学微电子考研分享群:(导学课直播回放可在b站"电路和微电子考研 ...

  3. CVPR 2020 | 更高质量的点云补全:上海交通大学团队提出点云分形网络

    点击上方"3D视觉工坊",选择"星标" 干货第一时间送达 本文由知乎作者1335授权转载,不得擅自二次转载.原文链接:https://zhuanlan.zhih ...

  4. 南开计算机和国立清华大学,同样来自交通大学,西安交通大学和上海交通大学,为何后来差距这么大?...

    在我国历史上,曾经有过很多非常有实力的大学,但由于历史原因,存的时间却并不长,在后来的大学合并和拆分中,从历史上消失了.比如西南联合大学,只存了短短的9年时间,最开始由清华大学.北京大学和南开大学合并 ...

  5. 重磅!上海交通大学取消博士论文发表要求!

    刚刚不久!上海交通大学研究生院网站公布2021年版<关于申请授予博士学位的规定>,新规正式取消博士研究生毕业需发表2篇论文的强制性要求. 2017年修订版则显示,"就读博士期间, ...

  6. 上海考研计算机专业院校排名,2018考研:计算机专业全球院校排名公布,上海交通大学竟排第一?...

    计算机专业算是老牌的热门院校,一直是热门被追赶,却从未被超越.近些年来考研报考计算机专业的考生仍然大有人在,计算机不仅在国内,甚至是国外都有着相当重要的地位.计算机专业全球院校排名已经公布,考生们跟着 ...

  7. 上海交通大学c语言章节作业,上海交通大学级C语言测试题.doc

    上海交通大学级C语言测试题 一. 选择题 (1)以下选项中,能用作用户标识符的是____ A)classB)forC)_2013D)2013_ (2)设有定义:int a,*pa=&a; 以下 ...

  8. python语言程序设计实践教程上海交通大学_《C语言实验与等级考试指导》隋雪莉 闵 芳 沈国荣著【摘要 书评 在线阅读】-苏宁易购图书...

    商品参数 作者: 隋雪莉 闵 芳 沈国荣著 出版社:上海交通大学出版社 出版时间:2018.9 印次:1-5 页数:282页 开本:正16开 ISBN:9787313161741 版权提供:上海交通大 ...

  9. 交大世界大学排名 计算机专业,2018考研:计算机专业全球院校排名公布,上海交通大学竟排第一?...

    计算机专业算是老牌的热门院校,一直是热门被追赶,却从未被超越.近些年来考研报考计算机专业的考生仍然大有人在,计算机不仅在国内,甚至是国外都有着相当重要的地位.计算机专业全球院校排名已经公布,考生们跟着 ...

最新文章

  1. SAP WM Picking Area的使用
  2. python网页爬虫-python网页爬虫浅析
  3. hdu1978(递推dp)
  4. php numeric乘法,PHP is_numeric()用法及代码示例
  5. Java学习笔记11-2——Spring5
  6. MRTG在Windows平台的安装及使用
  7. Blazor 状态管理
  8. Windows下安装MongoDB
  9. Django缓存设置
  10. 这也许是你不曾留意过的 Mybatis 细节 1
  11. Aspen hysys换热器修改计算模式Find Fouling模式
  12. 免费JSON格式的服务接口
  13. git cherry-pick的使用
  14. Cocos2dx游戏教程(十二):“见缝插针”,游戏结算界面和音效
  15. linux查看设备pid vid,Linux设备PID VID详细说明
  16. mysql里如何写日期格式_mysql 日期格式
  17. C++日期计算器的实现
  18. 计算机二级ms模拟题在线,全国计算机二级MSoffice高级应用模拟试题及答案
  19. BigDecimal如何比较大小
  20. Java虚拟机(Jvm详解)

热门文章

  1. 考勤管理系统(java课设+源码)
  2. knn鸢尾花数据集java_机器学习——鸢尾花数据集(Knn分类)
  3. 邹欣老师构建之法的自我评价
  4. 《易经》---曾仕强
  5. 监控android USB拔插
  6. C++成长历程 之 字符图形
  7. Spring boot 启动错误:Could not resolve placeholder
  8. 王国纪元显示服务器无回应,王国纪元常见问题解答_王国纪元常见问题汇总_牛游戏网...
  9. layui.laytpl的if else 写法
  10. 油气回收系统的组成方式