zoukankan      html  css  js  c++  java
  • HDU 3183 A Magic Lamp

    直接模拟   如果后一位比前一位小,那就一直 向前 pop()掉 维护他单调递增;

     1 #include<iostream>
     2 #include<cstring>
     3 #include<algorithm>
     4 #include<cmath>
     5 #include<stdio.h>
     6 #include<vector>
     7 using namespace std;
     8 
     9 char str[1123]; int res[1123],num;
    10 int main( )
    11 {
    12     while( scanf("%s%d",&str,&num) != EOF )
    13     {
    14         int len = strlen( str ); int k = 0;
    15         for( int i = 0; i < len; i++ )
    16         if( k != 0 && num != 0 && (str[i] - '0') < res[k] )
    17         {
    18             while( k != 0 && num != 0 && (str[i] - '0') < res[k] ){
    19                  k--; num--;
    20             }
    21               res[++k] = ( str[i] - '0' );
    22         }else res[++k] = ( str[i] - '0' );
    23          while( num-- && k != 0 )k--;
    24          bool fell = false; bool fall = false;
    25         for( int i = 1; i <= k; i++ )
    26         if(  res[i] == 0  ){ if( fell )cout<<res[i]; }
    27         else { fell = true; cout<<res[i]; }
    28         if( !fell ) cout<<0;puts("");
    29     }
    30     return 0;
    31 }
    View Code
  • 相关阅读:
    复制域 动态域
    字段
    ik分词器
    redis配置文件
    注解事务头部
    springSecurity配置解析
    sprring安全的.xml
    springSecurity需要的webxml
    nginx负载均衡+keepalived高可用
    20190802_Nginx基础
  • 原文地址:https://www.cnblogs.com/wulangzhou/p/3350454.html
Copyright © 2011-2022 走看看