False coin
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 16418   Accepted: 4583

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 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

题目大意:

这个银行从不同的来源收到了一些信息,在N个硬币中有一个硬币是假的,且它的重量与其他硬币的重量不同

在经济危机后,他们只有一个标准的平衡称,使用这个称,可以确定左边的是轻,还是重,或者等于右边的。

为了检测出这个假的硬币,这银行使用了一定数量的硬币,编号为1到n,因此分配给每个硬币不同的编号,

之后,他们开始将相同数目的不同组合硬币分别放入左右盘

这些硬币的标示符和重量都是被小心记录着。你需要写出一个程序可以帮助银行找出这个假硬币

就是根据记录寻找出假硬币

版权声明:本文为博主原创文章,未经博主允许不得转载。

Poj 1029 分类: Translation Mode 2014-04-04 10:18 112人阅读 评论(0) 收藏的更多相关文章

  1. 全面解析sizeof(上) 分类: C/C++ StudyNotes 2015-06-15 10:18 188人阅读 评论(0) 收藏

    以下代码使用平台是Windows7 64bits+VS2012. sizeof是C/C++中的一个操作符(operator),其作用就是返回一个对象或者类型所占的内存字节数,使用频繁,有必须对齐有个全 ...

  2. 修改MS SQL忽略大小写 分类: SQL Server 数据库 2015-06-19 09:18 34人阅读 评论(0) 收藏

    第一步:数据库->属性->选项->限制访问:SINGLE_USER 第二步:ALTER DATABASE [数据库名称] collate Chinese_PRC_CI_AI 第三步: ...

  3. 全面解析sizeof(下) 分类: C/C++ StudyNotes 2015-06-15 10:45 263人阅读 评论(0) 收藏

    以下代码使用平台是Windows7 64bits+VS2012. sizeof作用于基本数据类型,在特定的平台和特定的编译中,结果是确定的,如果使用sizeof计算构造类型:结构体.联合体和类的大小时 ...

  4. MS SQL 合并结果集并求和 分类: SQL Server 数据库 2015-02-13 10:59 92人阅读 评论(0) 收藏

    业务情景:有这样一张表:其中Id列为表主键,Name为用户名,State为记录的状态值,Note为状态的说明,方便阅读. 需求描述:需要查询出这样的结果:某个人某种状态的记录数,如:张三,待审核记录数 ...

  5. 菜鸟学习-C语言函数参数传递详解-结构体与数组 分类: C/C++ Nginx 2015-07-14 10:24 89人阅读 评论(0) 收藏

    C语言中结构体作为函数参数,有两种方式:传值和传址. 1.传值时结构体参数会被拷贝一份,在函数体内修改结构体参数成员的值实际上是修改调用参数的一个临时拷贝的成员的值,这不会影响到调用参数.在这种情况下 ...

  6. Nginx介绍 分类: Nginx 服务器搭建 2015-07-13 10:50 19人阅读 评论(0) 收藏

    海量请求,高性能服务器. 对比Apache, Apache:稳定,开源,跨平台,重量级,不支持高度并发的web服务器. 由此,出现了Lighttpd与Nignx:轻量级,高性能. 发音:engine ...

  7. jQuery中的on()和click()的区别 分类: 前端 HTML jQuery 2014-11-06 10:26 96人阅读 评论(0) 收藏

    HTML页面代码 <div> <h1>Click</h1> <button class="add">Click me to add ...

  8. Matlab调用C程序 分类: Matlab c/c++ 2015-01-06 19:18 464人阅读 评论(0) 收藏

    Matlab是矩阵语言,如果运算可以用矩阵实现,其运算速度非常快.但若运算中涉及到大量循环,Matlab的速度令人难以忍受的.当必须使用for循环且找不到对应的矩阵运算来等效时,可以将耗时长的函数用C ...

  9. 改变HTML中超链接的显示样式 分类: C1_HTML/JS/JQUERY 2014-08-27 10:11 595人阅读 评论(0) 收藏

    更详细的内容请参考:http://www.w3school.com.cn/tags/tag_a.asp HTML中的代码如下: <a class="news_title" t ...

随机推荐

  1. 模拟新浪微博textarea,刷新页面输入信息保留

    今天我们的产品经理提出一个新需求,模拟新浪微博textarea框,输入内容刷新页面保留信息. 我是用的方法是Html5 LocalStorage存储的,开始计划用cookie.或mysql存储,尝试了 ...

  2. delphi 基础之一 数据类型和基本语法

    1. 数据类型 特定类型 日期和时间 Delphi 也用实型数表示日期和时间数据.但为了更准确起见,Delphi 特别定义了TDateTime 数据类型,这是一个浮点类型,因为这个类型必须足够宽,使变 ...

  3. 【转载】学习C#的28条建议

    1. 看得懂的书,请仔细看:看不懂的书,请硬着头皮看:2. 别指望看第一遍书就能记住和掌握什么——请看第二遍.第三遍:3. 学习编程的秘诀是:编程,编程,再编程:4. 请把书上的程序例子亲手输入到电脑 ...

  4. Java 第七天 动态代理

    代理类需实现InvocationHandler接口: public interface InvocationHandler { public Object invoke(Object proxy,Me ...

  5. Java 第三天 Gradle和其它

    Gradle 是以 Groovy 语言为基础,面向Java应用为主.基于DSL(领域特定语言)语法的自动化构建工具. 下载地址 http://www.gradle.org/downloads 环境变量 ...

  6. 在EF的code frist下写稳健的权限管理系统:仓储设计(三)

    public class BaseRepository<T>:IBaseRepository<T> where T : class { protected EfConnecti ...

  7. 9.python的布尔类型与流程控制

    布尔类型其实可以算是一种特殊的数字,下面是 help() 函数得到的帮助信息: Help on class bool in module __builtin__: class bool(int) | ...

  8. 在mac上安装pydev for eclipse时,在eclipse的Preferences中无法显示出来的解决方法

    参考http://pydev.org/manual_101_install.html 中的说明,该插件依赖java7,在我安装eclipse之前并没有安装jdk,打开eclipse之后,自动安装了一个 ...

  9. Python Ogre Blender(转载)

    http://www.cppblog.com/Charlib/archive/2010/05/31/python_ogre_blender_1.html PyOgre入门以及如何使用Blender制作 ...

  10. spring debug

    DispatcherServlet{ getHandler()}handlerMappings{ RequestMappingHandlerMapping BeanNameUrlHandlerMapp ...