eroupean company's needs bonAppletit

/**
	 * bonAppletit
	 * 
	 * output
	 * overcharge
	 * number items:
	 * investigation volummn - Anna bill cost
	 * print "Anna was overcharged"
	 * 
	 * or not overcharge
	 * output: bonAppletit
	 * 
	 * eroupean company's  needs
	 * constriants:
	 * bill numSize: 2<=n<=10to5
	 * keyIndex: that Anna did not eat : 0<=k<n
	 * bill index of that order items cost: 0<=bill[i]<=10to4
	 * the amount of money that Bon chareged: 0<=b<=sum(bill[0],bill[n-1]) bill[i] is in this encloure
	 *
	 * @param bill
	 * @param k
	 * @param b
	 */
	public static void bonAppletit(List<Integer> bill,int k,int b) {
		if(bill==null) {
			return ;
		}
		if(bill.isEmpty()) {
			return ;
		}
		int intVal=1;
		for (int i = 0; i < 5; i++) {
			intVal*=10;
		}
		if(bill.size()<2 || bill.size()>intVal) {
			return ;
		}
		if(k<0 || k>=bill.size()) {
			return ;
		}
		int intVal1=1;
		for (int i = 0; i < 4; i++) {
			intVal1*=10;
		}
		for(Integer intTempItem : bill) {
			if(intTempItem<0 || intTempItem>intVal1) {
				return ;
			}
		}
		int sumE=0;
		for(Integer elementBillItem : bill) {
			sumE+=elementBillItem;
		}
		if(b<0 || b>sumE) {
			return ;
		}
		int itemBillSumEvitIndexItem=0;
		Integer integer = bill.get(k);
		for(Integer itemBill : bill) {
			if(itemBill==integer) {
				continue;
			}
			itemBillSumEvitIndexItem+=itemBill;
		}
		int averageCharge = itemBillSumEvitIndexItem/2;
		if(b>averageCharge) {
			System.out.println("Anna was overcharged");
		}else if(b==averageCharge){
			System.out.println("bonAppletit");
		}
		return ;
	}

#牛客AI配图神器#

#夸夸我的求职搭子##三一重工求职进展汇总##牛客创作赏金赛##硬件应届生薪资是否普遍偏低?##材料人,你们签了哪个公司#
Java技术 文章被收录于专栏

JavaEE技术 编程开发经验 企业通用技术

全部评论

相关推荐

纠结的无尾熊天天摸鱼:跟我完全一样的烂大街项目 面了十几家公司给我的感受就是非大厂的话对27届要求没有特别高,把简历上的东西背熟LeetCode也刷了这么多其实很容易就找到实习了
点赞 评论 收藏
分享
10-10 16:30
济宁学院 Java
不想做程序员:面试官:蓝桥杯三等奖?你多去两次厕所都能拿二等吧
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务