删数问题(贪心问题)SDUT OJ题
来源:互联网 发布:牛奶 知乎 编辑:程序博客网 时间:2024/06/10 19:58
删数问题
Time Limit: 1000MSMemory Limit: 65536KB
Problem Description
键盘输入一个高精度的正整数n(≤100位),去掉其中任意s个数字后剩下的数字按照原来的左右次序组成一个新的正整数。编程对给定的n与s,寻找一种方案,使得剩下的数字组成的新数最小。
Input
输入有多组 每组包括原始数n,要去掉的数字数s;
Output
输出去掉s个数后最小的数
Example Input
178543 4
Example Output
13
Hint
代码如下:
#include <stdio.h>#include <string.h>int main(){ char a[105]; int n,i,j,t,len; while(scanf("%s %d",a,&n)!=EOF) { len=strlen(a); t=n; if(n>=len) { printf("0\n"); continue; } while(n>0) { i=0; while(i<len&&a[i]<=a[i+1]) i++; for(j=i; j<len; j++) a[j]=a[j+1]; n--; } i=0; if(a[0]=='0') { while(a[i]=='0') i++; } if(i==len-t) printf("0"); for(j=i; j<len-t; j++) printf("%c",a[j]); printf("\n"); } return 0;}
1 0
- 删数问题(贪心问题)SDUT OJ题
- 删数问题 (sdut oj)
- [SDUT](2072)删数问题 ---贪心
- SDUT 贪心算法 删数问题
- 校OJ 8605 删数问题(贪心)
- sdut 删数问题
- SDUT--枚举(删数问题)
- 排序问题 (sdut oj)
- 约瑟夫问题 (sdut oj)
- 装船问题 (sdut oj)
- SDUT 2072 删数问题
- 删数问题(贪心)
- 删数问题(贪心)
- 删数问题(贪心)
- 删数问题(贪心问题)
- 【贪心】删数问题
- 【贪心】删数问题
- 贪心 删数问题
- mysql行列转换方法总结
- 无法检索 的元数据,无法识别的元素provider
- 数位DP
- 文件输入输出--重定向
- CentOS 7 安装 Elasticsearch5.2.2 的 Head 插件
- 删数问题(贪心问题)SDUT OJ题
- 模块化思想
- android继承BaseActivity
- hibernate入门一
- 一维数组的冒泡排序
- [AOP] 4. Spring AOP中提供的种种Aspects
- 怎么在自定义函数里更改主函数的数据取值
- ACM程序设计 书中题目Y
- 授权