- 集合删数
- 2014-12-01 18:09:46 @
自己搞定了!
#include <stdio.h>
#include <vector>
#include <queue>
#include <string.h>
#define LOCAL
char digit[200000];
int pivot = 0;
int KK, MM;
std::vector<int> nums;
std::deque<char> que;
void solve() {
scanf("%d %d", &KK, &MM);
nums.push_back(1);
int p2 = 0, p4 = 0;
for (int i=1; i<KK; i++){
int t2 = nums[p2]*2+1;
int t4 = nums[p4]*4+5;
if (t2 < t4){ nums.push_back(t2); p2++; }
else if(t2 > t4) { nums.push_back(t4); p4++; }
else { nums.push_back(t2); p2++;p4++; }
}
for(int i=0; i<KK; i++) {
pivot += sprintf(digit+pivot, "%d", nums[i]);
}
printf("%s\n", digit);
que.push_back('9');
int len = strlen(digit);
MM = len - MM;
for (int i=0; digit[i]; i++) {
char now = digit[i];
while (now>que.back() && (que.size()-1+(len-1-i)>=MM) ) { que.pop_back(); }
que.push_back(now);
}
que.pop_front();
while (que.size() > 0) {
printf("%c", que.front());
que.pop_front();
}
printf("\n");
}
int main () {
#ifdef LOCAL
freopen("test.in", "r", stdin);
//freopen("test.out", "w", stdout);
#endif
solve();
return 0;
}
2 条评论
-
Hzh123 LV 7 @ 2017-07-04 10:29:50
怎么搞定的???我也是第一个点过不了
-
2014-12-06 21:49:44@
请正确地发布源代码
- 1