HDU 6045 Is Derek lying?

思路:

判断不可行的条件。输入n,a,b,分别代表n的长度,分数a,分数b。same代表相同的个数。
1. 当a或b 大于n 时 不可行。
2. (asame)+(bsame)+same<=n 不满足这个的一定误解
3. 考虑当a大于notsame时,我们发现这时需要a-notsame个相同的题得正确。所以b需要大于等于a-notsame,同时b需要小于 nasame ,反之亦然。

#include<iostream>
#include<cstdio>
#include <queue>
#include<cstring>
#include<cmath>
#define inf 1e15
#define eps 1e-6
typedef long long int lli;
using namespace std;

char s1[180000];
char s2[180000];

int main(){
    int cas,a,b,len;
    scanf("%d",&cas);
    while(cas--){
        scanf("%d%d%d",&len,&a,&b);
        scanf("%s",s1);
        scanf("%s",s2);
        int same = 0,notsame = 0,flag = 1;
        for(int i = 0;s1[i];i++){
            if(s1[i] == s2[i]) same++;
            else notsame++;
        }
        if(a>notsame){
            if(b>=a-notsame && b<=same+len-a);
            else flag = 0;
        }
        if(b>notsame){
            if(a>=b-notsame && a<=same+len-b);
            else flag = 0;
        }
        if(a>len || b>len) flag = 0;
        if(a+b-same > len) flag = 0;
        if(!flag)
            puts("Lying");
        else
            puts("Not lying");
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值