zoukankan      html  css  js  c++  java
  • URAL1410. Crack

    1410

    dp水题 题意读了好一会 是不能连续读两个及以上单词 

     1 #include <iostream>
     2 #include<cstdio>
     3 #include<cstring>
     4 #include<algorithm>
     5 #include<stdlib.h>
     6 #include<vector>
     7 #include<queue>
     8 #include<cmath>
     9 using namespace std;
    10 #define N 10010
    11 int dp[N],len[N];
    12 char s[N][30],ss[N*100];
    13 int main()
    14 {
    15     int i,g=0;
    16     while(scanf("%c",&ss[g])!=EOF)
    17     {
    18         g++;
    19     }
    20     int t = 0,o=1;
    21     for(i = 0 ; i < g ; i++)
    22     {
    23         if((ss[i]>='a'&&ss[i]<='z')||(ss[i]>='A'&&ss[i]<='Z'))
    24         {
    25             s[o][t++] = ss[i];
    26         }
    27         else
    28         {
    29             if(t)
    30             {
    31                 s[o][t] = '';
    32                 len[o] = t;
    33                 t = 0;o++;
    34             }
    35         }
    36     }
    37     if(t)
    38     {
    39         s[o][t] = '';
    40         len[o] = t;
    41         t = 0;o++;
    42     }
    43     for(i = 1 ; i < o ; i++)
    44     {
    45         dp[i] = max(dp[i-1],dp[i-2]+len[i]);
    46     }
    47     cout<<dp[o-1]<<endl;
    48     return 0;
    49 }
    View Code
  • 相关阅读:
    hdu 1978
    hdu 2700
    hdu 1176
    hdu 2390
    hdu 2707
    hdu 1804
    hdu 2703
    hdu 2572
    hdu 1171
    React有状态组件和无状态组件
  • 原文地址:https://www.cnblogs.com/shangyu/p/3543462.html
Copyright © 2011-2022 走看看