编程练习:False coin

False coin【模拟】注意事项+易错数据 注意事项 每一组数据,可能又会有多个没有判断过,但是也可能只有一个没判断过,剩下全是真的,此时这个未判断过的就是答案。 但是如果有很多未判断过的,此时必须有一个判断为必假的,否则答案不确定。 如果一组数据两侧相等,那么他们全部是真的。 如果一组数据两侧不相等,那么除了他们之外全部的硬币都是真的。 两次判断相矛盾的硬币肯定是真的,比如有个硬币第一次判断是可能比较重,第二次又判断比较轻,如果是假的,... 阅读详情

http://poj.org/problem?id=1029


The "Gold Bar"bank received information from reliable sources that in their last group of N coins exactly one coin is false and differs in weight from other coins (while all other coins are equal in weight). After the economic crisis they have only a simple balance available (like one in the picture). Using this balance, one is able to determine if the weight of objects in the left pan is less than, greater than, or equal to the weight of objects in the right pan. 
In order to detect the false coin the bank employees numbered all coins by the integers from 1 to N, thus assigning each coin a unique integer identifier. After that they began to weight various groups of coins by placing equal numbers of coins in the left pan and in the right pan. The identifiers of coins and the results of the weightings were carefully recorded. 
You are to write a program that will help the bank employees to determine the identifier of the false coin using the results of these weightings. 
Input


The first line of the input file contains two integers N and K, separated by spaces, where N is the number of coins (2<=N<=1000 ) and K is the number of weightings fulfilled (1<=K<=100). The following 2K lines describe all weightings. Two consecutive lines describe each weighting. The first of them starts with a number Pi (1<=Pi<=N/2), representing the number of coins placed in the left and in the right pans, followed by Pi identifiers of coins placed in the left pan and Pi identifiers of coins placed in the right pan. All numbers are separated by spaces. The second line contains one of the following characters: '<', '>', or '='. It represents the result of the weighting: 
'<' means that the weight of coins in the left pan is less than the weight of coins in the right pan, 
'>' means that the weight of coins in the left pan is greater than the weight of coins in the right pan, 
'=' means that the weight of coins in the left pan is equal to the weight of coins in the right pan. 
Output


Write to the output file the identifier of the false coin or 0, if it cannot be found by the results of the given weightings.
Sample Input


5 3
2 1 2 3 4
<
1 1 4
=
1 2 5
=
Sample Output

3
Source
Northeastern Europe 1998

思路:

1)用 ”集合“ 来保存每组数据

2)false coin 在非“=”的集合中

3)集合对化简

     对于每一个非“=”的集合

            对于每一个 ”=“的集合的每一个元素

                   在非“=”集合把这些元素删除

      如 非“=”的集合只有唯一元素

              找到 false coins


POJ 1029 false coin POJ 1029 false coin题目链接 一堆硬币中有且仅有一枚假币,假币质量与其他币不等,根据给出的等式或不等式,判断哪一枚是假币,也有可能无法判断是否有假币 等式两边的必须是真币 不等式中一定有假币,且每一个不等式中,假币只会一直在大于的那边或者一直在小于的那边 normal set 记录正常的币,light 数组记录币在不等式中小的次数,heavy 数组记录币在不等式中大的次数 light/heavy中次数 = 不等式次数的,且不在normal set中的,且只有1个币符合这两个条件,那么 阅读详情

相关推荐

别再只会用555了!手把手教你用运放和RC电路搭一个50Hz正弦波信号源(附Multisim仿真文件)

本文详细介绍了如何使用运放LM358和RC电路搭建一个精准的50Hz正弦波信号源,涵盖文氏电桥核心原理、单电源供电解决方案、Multisim仿真及实物调试技巧。通过实战指南和优化建议,帮助电子爱好者快速掌握低频信号生成技术,适用于各种测试和校准场景。

weixin_34116482的博客 373

【九度】题目1486:False coin

题目描述: The "Gold Bar"bank received information from reliable sources that in their last group of N coins exactly one coin is false and differs in weight from other coins (while all other coins are e

wangzq的专栏 1070

傻白入门芯片设计,wafer/die/chip/cell(一)

芯片设计的一些基本概念

qq_46675545的博客 2万+

POJ-1029 False coin (模拟与暴力)

第一行以数字 Pi(1

2301_80844586的博客 984

TMS320F280039 CMD文件配置避坑指南:从.map文件看懂内存分配与溢出排查

本文详细解析了TMS320F280039芯片的CMD文件配置问题,通过.map文件分析内存分配与溢出排查。文章提供了实用的诊断技巧和解决方案,帮助开发者有效应对段溢出、地址重叠和栈堆冲突等常见问题,优化DSP程序的内存管理。

weixin_29168813的博客 452

VS2022命令行编译C++报错?一招解决‘fatal error C1034: iostream: 不包括路径集‘

本文针对VS2022命令行编译C++时常见的'fatal error C1034: iostream: 不包括路径集'错误,深入剖析了其根源在于环境变量缺失。文章提供了永久配置用户环境变量(PATH、INCLUDE、LIB)的一劳永逸解决方案,确保在任何终端中都能直接使用cl命令进行编译,并给出了进阶配置与常见错误排查指南。

weixin_29011667的博客 309

题目1486:False coin

题目描述: The “Gold Bar”bank received information from reliable sources that in their last group of N coins exactly one coin is false and differs in weight from other coins (while all other coins are equa

sun%moon 923

软件测试--用例篇(测试用例的好处、测试用例的七种设计方法、测试用例的粒度、测试用例的评价)

作为软件测试工程师,最主要的工作就是:编写测试用例,那么为什么要编写测试用例?它有什么好处?如何编写测试用例?测试用例写简单好还是复杂好?如何评价测试用例的质量? 天呐撸!能说不会吗?! 作为倾向软件测试工程师的老铁们,还是一起来学习吧! 一、编写测试用例的好处 测试用例是测试者的依据 测试用例使得工作可重复,是自动化测试的基础 补充:自动化测试的前提条件是:功能比较稳定,页面...

cherrydreamsover的博客 3740

False coin(P1029)

这个题还算比较巧妙 #include #include #include using namespace std; #define N 1011 int main() { int i,j,k; int total=0; char c; int t[N]={0}; int r[N]={0}; int w[N]={0}; int p; int n; cin>>

jiangjiashi的博客 787

ABB机器人将实时坐标发送给西门子PLC的具体方法示例

ABB机器人将实时坐标发送给西门子PLC的具体方法示例

Robot_PLC_HMI_Automation 4917

YOLOv11改进 - C3k2融合 | C3k2融合细节增强卷积DEConv(Detail-Enhanced Convolution)提升细微特征提取能力

本文介绍了细节增强卷积(DEConv)技术在YOLOv11中的结合应用。DEConv由标准卷积层和多种差异卷积层并行组成,通过计算像素差异和卷积操作增强特征提取能力,还采用重参数化技术简化模型结构。其优势在于能更好捕捉高频信息、保持参数数量不变且降低推理计算成本。我们将DEConv集成进YOLOv11,替换部分模块。

魔改工程师的博客 865

False coin

<br />False coin<br />Time Limit:1000MS  Memory Limit:65536K<br />Total Submit:31 Accepted:5 <br />Description<br />The "Gold Bar"bank received information from reliable sources that in their last group of N coins exactly one coin is false and differs in w

Rachel Zhang的专栏 2131

【StarRocks】-- DATETIME 与 TIMESTAMP 区别详解

本文详细解析了StarRocks中DATETIME/DATETIMEV2与TIMESTAMP的区别及使用场景。DATETIME系列存储人类可读时间,不携带时区;TIMESTAMP实际指Unix时间戳,建议用BIGINT存储。关键差异包括:精度选择(DATETIMEV2支持微秒级)、时区处理(仅函数计算时影响)、存储方式等。针对不同场景提供选型建议:单时区展示用DATETIMEV2,跨时区计算用BIGINT存储Epoch。特别强调与MySQL迁移时的注意事项,并给出常见问题解决方案和最佳实践清单,包括统一入口

欢迎来到我的博客,一起探索代码里的世界! 506

UVa 665 False Coin

该题目要求从N枚硬币中找出唯一的假币(可能偏重或偏轻),基于K次天平称量结果。通过枚举每枚硬币作为假币(偏轻或偏重)的情况,验证其是否与所有称量记录一致。若唯一确定则输出假币编号,否则输出0。解题关键在于模拟每次称量时,根据假币假设判断天平状态是否符合记录。算法时间复杂度为O(N*K),适用于题目给定的数据范围。

寂静山林 186

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

false coin

题目描述The "Gold Bar"bank received information from reliable sources that in their last group of N coins exactly one coin is false and differs in weight from other coins (while all other coins are equal ...

qq_38030194的博客 818

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

POJ1029 False coin【暴力】

False coin Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 26694 Accepted: 7594 Description The "Gold Bar"bank received information from reliable sources that in their last group of N coins exactly one coin is false and differs in weight from

海岛Blog 651

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

False Coin

时间限制:1秒 空间限制:65536K 热度指数:412 算法知识视频讲解题目描述The "Gold Bar"bank received information from reliable sources that in their last group of N coins exactly one coin is false and differs in weight from other co...

qq_30339595的博客 284

POJ 1029 False coin

False coin Time Limit:1000MS Memory Limit:65536K Total Submissions:22295 Accepted:6256 Description The "Gold Bar"bank received information from reliable sources that in their...

qq_41044309的博客 280

用 Cedar 策略语言为 Strands 智能体实现工具级授权:CedarAuthPlugin 设计解析与实战指南

AI 智能体(Agent)以用户身份自主调用工具,但"哪个用户被允许调用哪个工具"至今缺乏标准方案。本篇以 harness-sdk 仓库中的 [Cedar 授权设计文档](https://link.gitcode.com/i/dd46c192149b814c02fab4beb3cc2bde) 为骨架,结合仓库内已落地的 [CedarAuthorization 干预处理器实现](https://li

gitblog_00365的博客 817

poj 1029 False coin

做这个题目做了一下午 ,模拟类题目,跟前面做的那个1013一样的题目,首先用那种思想,但是在处理输出0这个状态上 那种方法太不方便了,要考虑很多很多情况,改了很久,还是WA,于是果断放弃那种方法,寻求另外一条思路,在这里 还是把那个代码贴出来,毕竟以后还是可以参考的 #include #include #include #define N 1000 int visit[N],weig

qwerty_xk的专栏 1084

ACM - False Coin

False Coin The "Gold Bar"bank received information from reliable sources that in their last group of N coins exactly one coin is false and differs in weight from other coins (while all other coins are...

times_cat的博客 371

九度题目1486:False coin

泪奔题……说不尽的尴尬 ,在POJ已经AC 九度至今还WA着呢 已疯。 在poj上终于找到一组没考虑的数据,就是多个个答案皆可的情况也要输出0,一开始想着要考虑的 写到后面就忘记了 代码思路 1、判断符号,等于号直接就标记OK,如果是大于号直接交换左右两边的位置,让他变成小于号 2、假设每一个硬币(最暴力方法),对于每一条表达式判断合不合理,注意在多个硬币都合理的情况下要输出0;

wxyfennie的博客 773

poj 1028 False coin

题目链接:点击打开链接

Baoli1008的专栏 730
上一篇: Hello 试用 breakpad (linux)
下一篇: 试用 Arduino Due
span76
博客等级 码龄18年 117粉丝 174原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址