Problem Description

Derek and Alfia are good friends.Derek is Chinese,and Alfia is Austrian.This summer holiday,they both participate in the summer camp of Borussia Dortmund.During the summer camp,there will be fan tests at intervals.The test consists of N choice questions and each question is followed by three choices marked “A” “B” and “C”.Each question has only one correct answer and each question is worth 1 point.It means that if your answer for this question is right,you can get 1 point.The total score of a person is the sum of marks for all questions.When the test is over,the computer will tell Derek the total score of him and Alfia.Then Alfia will ask Derek the total score of her and he will tell her: “My total score is X,your total score is Y.”But Derek is naughty,sometimes he may lie to her. Here give you the answer that Derek and Alfia made,you should judge whether Derek is lying.If there exists a set of standard answer satisfy the total score that Derek said,you can consider he is not lying,otherwise he is lying.

Input

The first line consists of an integer T,represents the number of test cases.

For each test case,there will be three lines.

The first line consists of three integers N,X,Y,the meaning is mentioned above.

The second line consists of N characters,each character is “A” “B” or “C”,which represents the answer of Derek for each question.

The third line consists of N characters,the same form as the second line,which represents the answer of Alfia for each question.

Data Range:1≤N≤80000,0≤X,Y≤N,∑Ti=1N≤300000

Output

For each test case,the output will be only a line.

Please print “Lying” if you can make sure that Derek is lying,otherwise please print “Not lying”.

Sample

Sample Input

AAA
ABC ABCBC
ACBCB Sample Output Not lying
Lying

题意:

  现在两个人同时回答一套题,ABC三个选项,只有一个是正确的,答对得一分,答错不得分,给出两个人的成绩和答案,判断这两个成绩是否合理。

  比如一共五个题,两个人的得分都是五分,然后两个人的答案都不相同,那么表示不合理。

思路:

  没什么技巧,就是推理题目。推理方法有很多种,只要合理就行。

  思路一:记录两个人答案相同的个数,如果  两个人成绩的和小于等于题目总数加上相同的个数  并且  两个人的分数差小于等于题目总数减去相同的个数,则表示没说谎。

  思路二:记录两人答案相同和不同的题数,如果  两个人成绩的和小于等于不同的个数加上两倍的相同的个数  并且   两个人分数差小于等于不相同的答案数,则表示没说谎

代码一:

/*
ACACBCA
BABACBB
*/
#include<stdio.h>
#include<math.h>
#include<cmath>
using namespace std;
char a1[],a2[];
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int n,x,y,i,j;
int butong=,xiangtong=;
scanf("%d%d%d",&n,&x,&y);
scanf("%s%s",a1,a2);
for(i=;i<n;i++)//计算相同和不同的个数
{
if(a1[i]==a2[i])
xiangtong++;
else
butong++;
}
if(x+y<=n+xiangtong&&abs(x-y)<=n-xiangtong)
printf("Not lying\n");
else
printf("Lying\n");
}
}

代码二:

/*
ACACBCA
BABACBB
*/
#include<stdio.h>
#include<math.h>
#include<cmath>
using namespace std;
char a1[],a2[];
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int n,x,y,i,j;
int butong=,xiangtong=;
scanf("%d%d%d",&n,&x,&y);
scanf("%s%s",a1,a2);
for(i=;i<n;i++)//计算相同和不同的个数
{
if(a1[i]==a2[i])
xiangtong++;
else
butong++;
}
if(abs(x-y)<=butong&&x+y<=butong+*xiangtong)
printf("Not lying\n");
else
printf("Lying\n");
}
}

hdu 6045 Is Derek lying?(思维推导)的更多相关文章

  1. HDU 6045 - Is Derek lying | 2017 Multi-University Training Contest 2

    /* HDU 6045 - Is Derek lying [ 分析 ] 题意: 有N个问题, 每个问题有A,B,C三种答案,答对加一分,答错不加分 给出甲乙两人的答案,给出两人的分数先x, y,问分数 ...

  2. HDU 6045 Is Derek lying?

    题目网址:http://acm.hdu.edu.cn/showproblem.php?pid=6045 题目: Is Derek lying? Time Limit: 3000/1000 MS (Ja ...

  3. 2017ACM暑期多校联合训练 - Team 2 1001 HDU 6045 Is Derek lying? (模拟)

    题目链接 Problem Description Derek and Alfia are good friends.Derek is Chinese,and Alfia is Austrian.Thi ...

  4. hdu 6045: Is Derek lying? (2017 多校第二场 1001)【找规律】

    题目链接 可以暴力找一下规律 比如,假设N=7,两人有5题相同,2题不同,枚举X=0->15时,Y的"Not lying"的取值范围从而找出规律 #include<bi ...

  5. 2017多校联合训练2—HDU6054--Is Derek lying?(思维题)

    Is Derek lying? Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

  6. 观光公交 [NOIP 2011] [思维推导]

    Description 风景迷人的小城Y 市,拥有n 个美丽的景点.由于慕名而来的游客越来越多,Y 市特意安排了一辆观光公交车,为游客提供更便捷的交通服务.观光公交车在第0 分钟出现在1号景点,随后依 ...

  7. HDU 6187 Destroy Walls (思维,最大生成树)

    HDU 6187 Destroy Walls (思维,最大生成树) Destroy Walls *Time Limit: 8000/4000 MS (Java/Others) Memory Limit ...

  8. HDU 6045 17多校2 Is Derek lying?

    题目传送:http://acm.hdu.edu.cn/showproblem.php?pid=6045 Time Limit: 3000/1000 MS (Java/Others)    Memory ...

  9. hdu 6045 多校签到题目

    http://acm.hdu.edu.cn/showproblem.php?pid=6045 题解:遍历一遍,求出两个人答案中相同的个数,用wa表示.然后我从大的数入手,当wa的数都尽可能在两个人答案 ...

随机推荐

  1. 自定义分布式RESTful API鉴权机制

    微软利用OAuth2为RESTful API提供了完整的鉴权机制,但是可能微软保姆做的太完整了,在这个机制中指定了数据持久化的方法是用EF,而且对于用户.权限等已经进行了封装,对于系统中已经有了自己的 ...

  2. 30岁程序员的选择,一线OR二线?

    作为一个30刚出头的IT行业从业者,先介绍下我自己的情况.虽然不具有代表性,但是也可以作为一个参考.本人08年本科毕业于一所还算不错的211大学计算机专业(04年去的时候综合排名38,毕业走时排名45 ...

  3. webpack前端工程化构建工具的使用

    一.模块打包机 1.创建文件 在目标文件下建立一个src文件夹作为js代码区:作为例子,我创建了两个js文件,并利用commonJS规范require引入到index.js中: moduleA.js: ...

  4. 在Cenos系统安装Python3.5版本,使P2和P3共存

    首先Cenos安装好后,系统自带python2.6版本 输入>>>exit()     退出 使用迅雷下载python3.5 链接:https://www.python.org/ft ...

  5. Petya勒索病毒疫苗出现,分分钟让电脑对病毒免疫

    继wannacry之后,Petya勒索软件攻击再次席卷全球,对欧洲.俄罗斯等多国政府.银行.电力系统.通讯系统.企业以及机场造成了不同程度的影响. 研究发现,Petya 会锁定磁盘的 MFT 和 MB ...

  6. mysql数据库和mongodb数据库的相关操作以及两个数据库的区别

    在docs命令中执行数据操作 MySQL数据库 先启动MySQL服务器  net start mysql 进入MySQL服务器MySQL -uroot -p(这里写你的数据库密码) (-P是从哪个端口 ...

  7. 【Android Developers Training】 75. 使用NSD

    注:本文翻译自Google官方的Android Developers Training文档,译者技术一般,由于喜爱安卓而产生了翻译的念头,纯属个人兴趣爱好. 原文链接:http://developer ...

  8. 关于拒绝测试驱动开发(NoTDD)

    今天在reddit看到微软某大牛的博客(https://blogs.msdn.microsoft.com/ericgu/2017/06/22/notdd/),说到拒绝TDD(测试驱动开发,下文统一使用 ...

  9. Azure SQL Database (23) Azure SQL Database Dynamic Data Masking动态数据掩码

    <Windows Azure Platform 系列文章目录> 我们在使用关系型数据的时候,有时候希望: - 管理员admin,可以查看到所有的数据 - 普通用户,某些敏感字段,比如信用卡 ...

  10. java 关于 hashmap 的实现原理的测试

    网上关于HashMap的工作原理的文章多了去了,所以我也不打算再重复别人的文章.我就是有点好奇,我怎么样能更好的理解他的原理,或者说使用他的特性呢?最好的开发就是测试~ 虽说不详讲hashmap的工作 ...