题目网址:http://acm.hdu.edu.cn/showproblem.php?pid=6045

题目:

Is Derek lying?

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 104    Accepted Submission(s): 65

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 Input
2
3 1 3
AAA
ABC
5 5 0
ABCBC
ACBCB
 
Sample Output
Not lying
Lying

思路:

纯粹的思维题,用cnt记录两人答案不一样的题数。通过观察可以得到两个结论:

1.fabs(x-y)<=cnt;//两者答对题目之差要小于等于不相同的答案数,取等的条件是对于不相同的答案 都是同一人答对

2.x+y<=2*n-cnt//两者答对题目之和要小于等于 题目总数的两倍减去不相同的答案,取等的条件是两人相同答案的题 全对

代码:

 #include <cstdio>
#include <cmath>
const int N=;
int main(){
int t;
int n,x,y;
char D[N],A[N];
scanf("%d",&t);
while(t--){
int cnt=;
scanf("%d%d%d ",&n,&x,&y);
gets(D);
gets(A);
for(int i=;i<n;i++){
if(D[i]!=A[i]) cnt++;
}
if(fabs(x-y)>cnt || (x+y)>(*n-cnt)) printf("Lying\n");
else printf("Not lying\n");
}
return ;
}

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?(思维推导)

    Problem Description Derek and Alfia are good friends.Derek is Chinese,and Alfia is Austrian.This sum ...

  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. HDU 6045 17多校2 Is Derek lying?

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

  7. hdu 6045 多校签到题目

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

  8. 【多校联合】(HDU6045)Is Derek lying?

    分析 之前没有想到题目解法,看了题解才会,记录一下思考过程. 这条题目的实质是,在满足合法的情况下,有没有a和d的可行解?也就是说,不要仅仅附在表面的思考逻辑条件,而是要思考实际的数学表达. 转化为数 ...

  9. 【2017 Multi-University Training Contest - Team 2】 Is Derek lying?

    [Link]: [Description] 两个人都做了完全一样的n道选择题,每道题都只有'A','B','C' 三个选项,,每道题答对的话得1分,答错不得分也不扣分,告诉你两个人全部n道题各自选的是 ...

随机推荐

  1. jmeter linux分布式压测Server failed to start: java.rmi.server.ExportException: Listen failed on port: 0; nested exception is: java.io.FileNotFoundException: rmi_keystore.jks

    在路径\apache-jmeter-5.0\bin下启动jmeter-server.bat时抛出了如下异常: 1.jmeter 1099端口 被占用,修改端口号 使用netstat -lntp|gre ...

  2. elasticsearch Discovery 发现模块学习

    发现模块和集群的形成 目标 发现节点 Master选举 组成集群,在Master信息发生变化时及时更新. 故障检测 细分为几个子模块 Discovery发现模块 Discover是在集群Master节 ...

  3. wrk,ab,locust,Jmeter 压测结果比较

    背景: 项目需要对一批接口进行压测,要求是接口的QPS(Quest Per Second每秒请求数)达到6万以上由于楼主一直使用的压力测试工具是jmeter,但是jmeter单台电脑无法达到6万的QP ...

  4. Widget 基础

    一切皆Widget Widget 渲染过程 Flutter把视图数据的组织和渲染抽象为三部分,即 Widget.Element 和 RenderObject. Widget Widget 是空间实现的 ...

  5. pycharm最新版本激活码(永久有效) python安装教程

    Mac 系统自带python 1.打开终端, 输入 python 可以查看python当前版本. 2.输入“python”回车后即进入解释器,例如打印“hello world!”, 可输入 ‘ pri ...

  6. 【linux】【jenkins】自动化部署一 安装jenkins及Jenkins工作目录迁移

    系统环境:Centos7 https://jenkins.io/zh/download/ 下载对应系统的jenkins 一.安装jdk8.0 jenkins安装需要jdk8or11,根据jenkins ...

  7. Java中自定义注解类,并加以运用

    在Java框架中,经常会使用注解,而且还可以省很多事,来了解下自定义注解. 注解是一种能被添加到java代码中的元数据,类.方法.变量.参数和包都可以用注解来修饰.注解对于它所修饰的代码并没有直接的影 ...

  8. selenium-03-02操作元素-等待

    1.最直接普通的方式:这个是设置固定的等待时间    Thread.sleep(1000);   2.隐式等待方式(implicitlyWait):设置脚本在查找元素时的最大等待时间:    driv ...

  9. windows核心编程 第5章job lab示例程序 解决小技巧

    看到windows核心编程 第5章的最后一节,发现job lab例子程序不能在我的系统(win8下)正常运行,总是提示“进程在一个作业里”         用process explorer程序查看 ...

  10. kubeadm部署高可用集群Kubernetes 1.14.1版本

    Kubernetes高可用集群部署 部署架构: Master 组件: kube-apiserver Kubernetes API,集群的统一入口,各组件协调者,以HTTP API提供接口服务,所有对象 ...