浙江工商大学15年校赛C题 我删我删,删删删 【简单模拟】
2015-03-24 10:41
211 查看
Description: 有一个大整数.不超过1000位.假设有N位.我想删掉其中的任意S个数字.使得删除S位后,剩下位组成的数是最小的. Input: 有多组数据数据,每组数据为两行.第一行是一个大整数.第二行是个整数S,其中S小于大整数的位数. 输入以EOF结束。 Output: 对于每组输入数据,请输出其删除后的最小数. Sample Input: 178543 4 100002 1 Sample Output: 13 2
解题思路:
删除比它下一位大的数字,删除S次即可
注意的是要对答案取出前导0
Source Code:
//#pragma comment(linker, "/STACK:16777216") //for c++ Compiler #include <stdio.h> #include <iostream> #include <fstream> #include <cstring> #include <cmath> #include <stack> #include <string> #include <map> #include <set> #include <list> #include <queue> #include <vector> #include <algorithm> #define Max(a,b) (((a) > (b)) ? (a) : (b)) #define Min(a,b) (((a) < (b)) ? (a) : (b)) #define Abs(x) (((x) > 0) ? (x) : (-(x))) #define MOD 1000000007 #define pi acos(-1.0) using namespace std; typedef long long ll ; typedef unsigned long long ull ; typedef unsigned int uint ; typedef unsigned char uchar ; template<class T> inline void checkmin(T &a,T b){if(a>b) a=b;} template<class T> inline void checkmax(T &a,T b){if(a<b) a=b;} const double eps = 1e-7 ; const int N = 210 ; const int M = 1100011*2 ; const ll P = 10000000097ll ; const int MAXN = 10900000 ; const int INF = 0x3f3f3f3f ; const int offset = 100 ; string ch; char Min; int n, m; int main() { std::ios::sync_with_stdio(false); int i, j, t, k, u, c, v, p, numCase = 0; while (cin >> ch) { n = ch.size(); cin >> m; while (m--) { bool flag = true;//ADD Min = ch[0]; for (i = 1; i < n; ++i) { if (Min > ch[i]) { for (j = i; j <= n; ++j) { ch[j - 1] = ch[j]; } flag = false;//ADD --n; break; } else { Min = ch[i]; } } if (flag) { //ADD --n; //ADD } //ADD } i = 0; for (;;) { if (ch[i] == '0') { ++i; continue; } break; } if (i == n) { cout << 0 << endl; } else { for (; i < n; ++i) { cout << ch[i]; } cout << endl; } } return 0; }
相关文章推荐
- 浙江工商大学15年校赛E题 无邪的飞行棋 【经典背包】
- 浙江工商大学15年校赛I题 Inversion 【归并排序求逆序对】
- [模拟] 简单的进程调度模拟
- 在MIDP1.0中简单模拟图片翻转功能
- 用AJAX实现google输入自动完成的简单模拟
- 使用java简单模拟ping和telnet的实现
- 使用java简单模拟ping和telnet的实现
- 防止模拟键盘一类工具操作自己的系统的“简单实现”
- 基于ODE的 简单的布料模拟demo
- QQ界面的简单模拟
- 使用java简单模拟ping和telnet的实现
- 半透明物体边缘透射的简单模拟
- WinForm学习 --简单的模拟时钟程序
- 在 ASP.NET 中用匿名委托简单模拟 AOP 做异常和日志处理
- 用AJAX实现google输入自动完成的简单模拟
- WinForm学习(1) --简单的模拟时钟程序
- 简易NPR(二) -- 水墨风格的简单模拟
- JavaScript一点也不简单—实现“跨Frame的层模拟菜单”的方法(译文)
- 一个简单实用的模拟选项夹的代码
- 在ASP.NET 中模拟简单数字注册码的生成