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 }


  • 相关阅读:
    【iOS基础控件 6 】 汽车品牌展示 Model嵌套/KVC/TableView索引 <UITableView>
    RAC
    Magical Data Modelling Framework for JSON
    Xcode插件管理工具Alcatraz
    iOS8 Size Classes的理解与使用
    Storyboard、xib中的UIScrollView使用autolayout,使其能够滚动
    iOS事件响应链
    git一些常用的操作(转载)
    iOS本地数据存储(转载)
    使用react-native做一个简单的应用-04界面主框架
  • 原文地址:https://www.cnblogs.com/0xiaoyu/p/11370170.html
Copyright © 2011-2022 走看看