zoukankan      html  css  js  c++  java
  • Lweb and String HDU

     
    一水题
     
    Lweb has a string S. 

    Oneday, he decided to transform this string to a new sequence. 

    You need help him determine this transformation to get a sequence which has the longest LIS(Strictly Increasing). 

    You need transform every letter in this string to a new number. 

    A is the set of letters of SS, BB is the set of natural numbers. 

    Every injection f:Acan be treat as an legal transformation. 

    For example, a String “aabc”, A={a,b,c},  and you can transform it to “1 1 2 3”, and the LIS of the new sequence is 3. 

    Now help Lweb, find the longest LIS which you can obtain from SS. 

    LIS: Longest Increasing Subsequence. (https://en.wikipedia.org/wiki/Longest_increasing_subsequence)
     

    Input

    The first line of the input contains the only integer T,(1T20)

    Then T lines follow, the i-th line contains a string S only containing the lowercase letters, the length of SS will not exceed 105.

    Output

    For each test case, output a single line "Case #x: y", where x is the case number, starting from 1. And y is the answer.

    Sample Input

    2
    aabcc
    acdeaa

    Sample Output

    Case #1: 3
    Case #2: 4

    题意:

    咱也不知道这道题什么情况,搞半天是求多少种不同字符



     1 #include <stdio.h>
     2 #include <string.h>
     3 
     4 int main()
     5 {
     6     int len, i, t, book[105];
     7     char a[100005];
     8     scanf("%d", &t);
     9     int cas = 0, ans;
    10     while(t--)
    11     {
    12         scanf("%s", a);
    13         ans = 0;
    14         len = strlen(a);
    15         memset(book, 0, sizeof(book));
    16         for(i=0; i<len; i++)
    17         {
    18             if(book[a[i]-'a']==0)
    19             {
    20                 ans++;
    21                 book[a[i]-'a'] = 1;
    22             }
    23         }
    24         printf("Case %d: %d
    ", ++cas, ans);
    25     }
    26     return 0;
    27 }


  • 相关阅读:
    附近有什么?8款可以查周边的App
    实体店里充话费要怎么弄
    怎样买手机号?
    手机号是SIM卡的号呢,还是买手机时就带的
    网站SSL证书在线检测
    未来什么行业最赚钱
    陈安之-如何选择最赚钱的行业
    斗鱼宣布获C轮15亿融资 直播行业进入资本时代
    2016年Godaddy最新域名转出教程
    GoDaddy账户间域名转移PUSH以及ACCEPT接受域名过户方法
  • 原文地址:https://www.cnblogs.com/0xiaoyu/p/11370170.html
Copyright © 2011-2022 走看看