A Magic Lamp(RMQ)

A Magic Lamp

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2041    Accepted Submission(s): 816


Problem Description
Kiki likes traveling. One day she finds a magic lamp, unfortunately the genie in the lamp is not so kind. Kiki must answer a question, and then the genie will realize one of her dreams. 
The question is: give you an integer, you are allowed to delete exactly m digits. The left digits will form a new integer. You should make it minimum.
You are not allowed to change the order of the digits. Now can you help Kiki to realize her dream?
 

Input
There are several test cases.
Each test case will contain an integer you are given (which may at most contains 1000 digits.) and the integer m (if the integer contains n digits, m will not bigger then n). The given integer will not contain leading zero.
 

Output
For each case, output the minimum result you can get in one line.
If the result contains leading zero, ignore it. 
 

Sample Input
178543 4 1000001 1 100001 2 12345 2 54321 2
 

Sample Output
13 1 0 123 321
 


RMQ,但是里面有很多细节问题需要注意一下!先讲一下为什么是RMQ算法,假如

 

有个数是6位数减去两个数就代表顺序选择四位数,第一位数必须在1-3内选择,第二

 

个数必

 

须在第一个数之后到剩下的位数之内选择,以此类推!也就是贪心法则!用RMQ计

 

算区间最小值比较方便!

 

/*
这一题遇到几个比较棘手的问题:
如果直接求最小值,但是如何找到最小值的位置
就是一个比较严重的问题
所以我们应该怎么办啊?
*/
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
const int N=1010;
int minsum[N][20];
int m;
char s[N],ans[N];
/*
void RMQ(int n)
{
    int i,j;
    for(i=1;i<=stl;i++)
    {
        minsum[i][0]=s[i]-'0';
    }//初始化
    for(j=1;j<20;j++)
    {
        for(i=1;i<=stl;i++)
        {
            if(i+(i<<j)-1<=stl)
            {
                minsum[i][j]=min(minsum[i][j-1],minsum[i+(1<<(j-1))][j-1]);
            }
        }
    }
}
如上所述,如果直接求的是最小值就找不到位置了,怎么解决呢?
*/
int mins(int a,int b)
{
    return s[a]<=s[b]?a:b;
}//return的是位置而不是字符!记住了!
void RMQ(int n)
{
    int i,j;
    for(i=0;i<n;i++)
    {
        minsum[i][0]=i;//记住这里minsum[][]记录的是位置而不是字符
    }//初始化
    for(j=1;(1<<j)<n;j++)
    {
        for(i=0;i<=n;i++)
        {
            if(i+(1<<j)-1<n)
            {
                minsum[i][j]=mins(minsum[i][j-1],minsum[i+(1<<(j-1))][j-1]);//这个也是位置!
            }
        }
    }
}
int query(int a,int b)
{
    int c=(int)(log(b-a+1.0)/log(2.0));
   // cout<<"c="<<c<<endl;
    return mins(minsum[a][c],minsum[b-(1<<c)+1][c]);
}
int main()
{
    int p,st,ed,i,stl;
    while(cin>>s>>m)
    {
        stl=strlen(s);
     //   cout<<s<<"  "<<m<<" "<<stl<<" "<<endl;
        RMQ(stl);
        p=st=0;
        ed=stl-m;
      /*  for(i=1;i<=stl-ed;i++)
        {
            cout<<"选择区间为:"<<st<<" --"<<st+m<<endl;
            st=query(st,st+m);
            cout<<"st="<<st<<endl;
            ans[p++]=s[st++];
            cout<<"选择后:st="<<st<<endl;
        }*/
        /*
        前面的算法是错的?为什么呢?区间的大小不是固定的你比如最后一个
        实例!54321这样算我们知道区间是3第一个获取的数是3那么应该在3-6获取
        则第二个数就是1了,实际上他应该是2再说了,算出了1后面又不知道怎么
        结束了,所以需要改进!怎么改进呢?

        */
        while(ed--)
        {
            st=query(st,stl-ed-1);
            ans[p++]=s[st++];
        }
        for(i=0;i<p;i++)
        {
            if(ans[i]!='0')
            {
                break;
            }
        }
        if(i==p)
        {
            cout<<0<<endl;
        }
        else
        {
            while(i<p)
            {
                cout<<ans[i];
                i++;
            }
            cout<<endl;
        }
    }
}


 

内容概要:论文提出了一种基于空间调制的能量高效分子通信方案(SM-MC),将传输符号分为空间符号和浓度符号。空间符号通过激活单个发射纳米机器人的索引来传输信息,浓度符号则采用传统的浓度移位键控(CSK)调制。相比现有的MIMO分子通信方案,SM-MC避免了链路间干扰,降低了检测复杂度并提高了性能。论文分析了SM-MC及其特例SSK-MC的符号错误率(SER),并通过仿真验证了其性能优于传统的MIMO-MC和SISO-MC方案。此外,论文还探讨了分子通信领域的挑战、优势及相关研究工作,强调了空间维度作为新的信息自由度的重要性,并提出了未来的研究方向和技术挑战。 适合人群:具备一定通信理论基础,特别是对纳米通信和分子通信感兴趣的科研人员、研究生和工程师。 使用场景及目标:①理解分子通信中空间调制的工作原理及其优势;②掌握SM-MC系统的具体实现细节,包括发射、接收、检测算法及性能分析;③对比不同分子通信方案(如MIMO-MC、SISO-MC、SSK-MC)的性能差异;④探索分子通信在纳米网络中的应用前景。 其他说明:论文不仅提供了详细的理论分析和仿真验证,还给出了具体的代码实现,帮助读者更好地理解和复现实验结果。此外,论文还讨论了分子通信领域的标准化进展,以及未来可能的研究方向,如混合调制方案、自适应调制技术和纳米机器协作协议等。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值