zoukankan      html  css  js  c++  java
  • HDU 6045 Is Derek lying? 思维

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

      题目大意: 给定两个长度相等的字符串, 给出一组比分, 问这组比分是否可能。

      解题思路: 统计两个字符串字符的相同数和不同数, 两者相差小于等于不同数, 两者相加减去一倍的相同数<=n

      代码: 

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <string>
    #include <algorithm>
    using namespace std;
    
    const int N=80004;
    char xx[N],yy[N];
    int main()
    {
        int t,n,x,y;
        scanf("%d",&t);
        while(t--){
            scanf("%d%d%d",&n,&x,&y);
            scanf("%s",xx);
            scanf("%s",yy);
            int ans=0;
            for(int i=0;i<n;i++){
                if(xx[i]==yy[i])ans++;
            }
            if(x+y<=(n+ans)&&abs(y-x)<=(n-ans)){
                printf("Not lying
    ");
            }
            else printf("Lying
    ");
        }
        return 0;
    }
    View Code

      思考: 这题应该是一道水题的, 但是我进入了思想的误区, 一个范围这道题就出来是对的, 但是我......哎, 没法说, 题见得还是太少了

  • 相关阅读:
    oracle—数据泵及常用参数
    NTP服务及时间同步
    kudu安装
    ogg12c 配置
    ogg12-ERROR OGG-01031 file D:OGGdirdated000000 is not in any allowed output directories
    ogg12c_静默安装
    git的基本使用
    redis数据库
    linux之网络
    flask框架基础
  • 原文地址:https://www.cnblogs.com/FriskyPuppy/p/7258343.html
Copyright © 2011-2022 走看看