首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >eroupean company's needs bonAppletit

eroupean company's needs bonAppletit

原创
作者头像
程序员编程助手科技
发布2025-07-12 14:37:48
发布2025-07-12 14:37:48
520
举报
文章被收录于专栏:Java技术Java技术
代码语言:java
复制
/**
	 * 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 ;
	}

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档