标签:++ amp cin 小数 show 时间 限制 精度 php
链接:http://ybt.ssoier.cn:8088/status.php?start=0&showname=edsheeran&showpid=&showres=&showlang=
输入一个高精度的正整数n,去掉其中任意s个数字后剩下的数字按原左右次序组成一个新的正整数。编程对给定的n和s,寻找一种方案使得剩下的数字组成的新数最小。
输出新的正整数。(n不超过240位)
输入数据均不需判错。
n
s
最后剩下的最小数。
175438 4
13
#include<iostream> #include<cstring> #include<algorithm> #include<cstdio> using namespace std; int main() { string n; int s; cin>>n; int l=n.length(); cin>>s; for(int i=1;i<=s;i++) { for(int j=0;j<l-1;j++) if(n[j]>n[j+1]) { for(int k=j;k<l;k++)n[k]=n[k+1]; break; } l--; } int i=0; while(i<l&&n[i]-‘0‘==0)i++; if(i==l)cout<<"0"<<endl; else for(;i<l;i++)cout<<n[i]; }
标签:++ amp cin 小数 show 时间 限制 精度 php
原文地址:http://www.cnblogs.com/EdSheeran/p/7750238.html