#include <stdio.h>
#define NONE 'n'
/*
升序数列,删除前面的高位
降序数列,删除后面的低位
先处理升序
*/
char n[1009];
int k;
// find the next digit after digit a, return -1 when can not find.
int next(int a) {
++a;
while (n[a] == NONE){
++a;
}
if (n[a] == '\0') {
return -1;
}
return a;
}
// find avialable digit befor the digit, if do not have, find after it.
int pre(int a) {
int b = a;
--a;
while (a >= 0 && n[a] == NONE){
--a;
}
if (a < 0) {
return next(b);
}
return a;
}
int main() {
scanf("%s%d", n, &k);
int i = 0;
while (k > 0) { // 处理升序
int j = next(i);
if (j == -1) {
break;
}
if (n[i] < n[j]) { // asc ?
n[i] = NONE;
--k;
i = pre(i);
}
else {
i = j;
}
}
while (k > 0) { //如果有,处理剩余的降序
n[i] = NONE;
--k;
i = pre(i);
}
i=0;
while (n[i] != '\0') {
if (n[i] != NONE) {
putchar(n[i]);
}
++i;
}
return 0;
}
相关推荐
树莓派4B:控制步进电机
文章目录准备阶段接线阶段树莓派程序 准备阶段 准备以下物品,淘宝都可以买到: 57步进电机 电源开关(220v转24v,3A,72W) 步进电机驱动器 电源线 电线 杜邦线 树莓派4B一套 具体型号如下: 接线阶段 整体:接线效果如下图 电源开关起220v转24v作用,很好接线,输出24v接入步进电机驱动器 步进电机驱动器的 A+ A- B+ B- 按提示接步进电机四线,步进电机上就会有说...
sgu296:Sasha vs. Kate(贪心)
题目大意: ~~~~~~给定一个正整数 n(1≤n≤101000) ~n(1\leq n \leq 10^{1000})~和一个非负整数 k ~k~,要求你删去 n ~n~中的 k ~k~个数字,使得剩下的数最大,保证 k ~k~小于 n ~n~的位数,且 n ~n~没有前导零。分析: ~~~~~~我们只需从高位向低位贪心的取最大值即可。AC code:#include
SAP ABAP实战:如何用CVI_EI_INBOUND_MAIN批量更新BP邮箱(附完整代码)
本文深入解析了SAP ABAP中CVI_EI_INBOUND_MAIN函数在业务伙伴(BP)邮箱地址批量维护场景下的应用。通过详细讲解数据结构构建、关键参数(如任务参数'5')配置及完整代码示例,为开发者提供了一套高效、稳定的批量更新解决方案,并分享了性能优化与错误处理的最佳实践。
SGU 296 Sasha vs. Kate ( 贪心 )
题意很好懂,就是下午脑抽,wa了8次卡了4个小时。。。 1. 一开始直接0~9的个数,先去0、再去1。。直到凑足个数。。。一定是前天做的题用到了统计此刻大脑还有残留。。。 2. 自作聪明,明明看到题目里k严格小于所给数字的位数,还加了特判,当k等于位数时输出0.。。。作死。 3. 先找到最大的数字(一个位的),然后在其第一次出现的地方左边依次去掉k个最小的数,如果不足k个则在右侧去除直...
高缺失率时空数据插补实战:从随机森林到扩散模型的性能对比
数据缺失是数据分析与机器学习建模中普遍面临的挑战,尤其在时空数据领域,传感器故障、传输中断等问题常导致数据不完整。数据插补技术旨在基于已知数据的模式和关联性,合理估算缺失值,为后续分析提供可靠基础。其核心原理在于利用数据的时空相关性(如时间周期性、空间邻近性)及与外部驱动因素(如交通、气象)的关联构建预测模型。这项技术的价值在于能将不完整的数据集转化为可用于高质量分析和预测的可用资产,广泛应用于环境监测、交通流量预测、金融风控等领域。本文聚焦于一个极具挑战性的场景——PM2.5监测数据缺失率高达82%,通过
COMSOL实战:如何用有限元法(FEM)准确仿真电磁场问题?避坑指南
本文是一份COMSOL电磁场仿真实战指南,重点讲解如何运用有限元法(FEM)准确模拟电磁场问题。文章通过矩形波导和偶极子天线两大经典案例,详细剖析了从几何建模、物理场设置、网格剖分到结果验证的全流程,并提供了处理非线性材料、求解器收敛失败等高级问题的避坑技巧,旨在帮助工程师建立可靠的仿真工作流。
sgu 296. Sasha vs. Kate 贪心
296. Sasha vs. KateTime limit per test: 0.5 second(s)Memory limit: 65536 kilobytesinput: standardoutput: standardDuring the regular Mars's World Finals Subregional Programming Contest a boy Sasha lost...
Unreal5从入门到精通之Landscape地形系统
虚幻引擎 5 (UE5) 能够利用其强大的地形编辑工具套件创建大规模的地形世界。使用地形工具可以创建身临其境的户外地形,这些地形经过优化,可在多种不同设备上保持可播放的帧速率。
今日SGU 5.22
SGU 296 题意:给你一个最多1000位的数,让你删除k位使得剩下的数最大 收获:贪心 #include<bits/stdc++.h> #define de(x) cout<<#x<<"="<<x<<endl; #define dd(x) cout<<#x<<"="<<x<&...
新手必看:C#调用YOLO模型完成图片/视频目标检测(上位机版)
新手学习C#调用YOLO模型,核心是先把基础流程跑通,再逐步优化。图片检测是基础,视频检测就是在图片的基础上加循环和线程,而上位机的实际项目,就是在这个基础上适配工业硬件和业务需求。本文的代码都是新手能直接复制运行的,如果你运行时遇到问题,先检查前期准备是否到位,再看避坑指南。记住,新手别追求一步到位,先实现功能,再慢慢优化性能和界面。等你能熟练调用YOLO模型后,再去研究模型训练、量化优化等进阶内容,会轻松很多。
Java代码实现opc ua 事件订阅和数据变化订阅
OPC UA (Open Platform Communications Unified Architecture) 提供了两种主要的订阅机制:数据变化订阅(Data Change Subscription)和事件订阅(Event Subscription)。这两种订阅机制允许客户端实时接收来自服务器的数据更新或事件通知。
SGU 296.Sasha vs. Kate(贪心)
题意: 给出长度为n(<=1000)的一个数。输出删掉k个数字后的最大值。 Solution: 简单贪心。 s[i]代表数字s的第i位. 从前往后第一个满足s[i]>s[i-1]的位置,最优一定是删除s[i-1]的.累计次数t. 同时对新得到的数同样处理,这里可以只用一个循环.如果用c++ string的话更加方便. ...
基于 ESP32 与 TDS 传感器的水培营养液离子浓度自动配比系统设计与实现
本系统以 ESP32 为主控芯片,结合 TDS(总溶解固体)传感器实时监测水培营养液中的离子浓度,通过蠕动泵自动补充浓缩营养液或清水,实现营养液 EC 值的闭环自动配比。系统适用于家庭及小型农场的水培种植场景,可稳定维持营养液浓度在作物生长所需的最佳区间。
SGU - 296 - Sasha vs. Kate
上题目: 296. Sasha vs. Kate Time limit per test: 1 second(s)Memory limit: 65536 kilobytes input: standardoutput: standard During the regular Mars's World Finals Subregional Programming Contes...
SAP B1中文培訓教材_SDK
公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说
廖雪峰Python教程[完整版]
廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白
我一万年也不更新一次博客
sgu 270-280 sgu270 分类讨论,考虑各种各样的情况 sgu271 简单的splay翻转 sgu272 题目只需要找出任意一种合法方案,那么一遍一遍dfs直到dfs不动了就行了 sgu273 题意是给你一个由b,r,w,y组成的串,并且给定若干个规则,每个规则的意思是相邻的两个字母可以合并成另一个字母,问这个串最终能合并成哪几个字母。 DP。\(f[i][j][c]\)表...
深度学习工具包 DeepLearningToolbox
深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[](https://bitdeli.com/free "Bitdeli Badge")
sgu 题目总结。
codeforces上能交sgu上的老题了,什么时候可以刷完呢?100.A+B 101.欧拉回路102.欧拉函数104.动态规划,输出方案105.找规律107.找规律111.大数开方,我用的java二分。。。112.大数java用到快速输入输出,不要用Scanner113.素数115.水117.快速幂取模123.递推130.卡特兰数133.贪心134.树形dp135.找规律154.二分 阶乘找五1...
Outlook Express 6 (OE6) for Win7/Win8/Win10
英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。
AtCoder Beginner Contest 296 G.Polygon and Points(计算几何/凸包上二分)
AtCoder Beginner Contest 296 G.Polygon and Points(计算几何/凸包上二分)
SGU AC人数排序 可以用来确定刷题顺序
SGU AC人数排序 此谓刷题进TOP10的必备神器!
sgu 135. Drawing Lines 找规律
135. Drawing Linestime limit per test: 0.25 sec. memory limit per test: 4096 KBLittle Johnny likes to draw a lot. A few days ago he painted lots of straight lines on his sheet of paper. Then he counte...
WeakAuras Lua Script [ICC BOSS 12 - The Lich King]
WeakAuras Lua Script [ICC BOSS 12 - The Lich King] 巫妖王脚本 瓦格里指示器
sgu oj 说明
做sgu oj的一些ac代码 sgu地址 : http://acm.sgu.ru/ 我的帐号 052435
sgu 125
AC之后看大网上别人的基本是dfs、暴力搜索 因为我的算法不是这样,贴出来看看 sgu结果: Accepted 31 ms 835 kb 英文很烂,注释看不懂可email /** * @file * @brief my c solution for problem 125 on SGU OJ * @author ck * @date 2013-06-19 *
sgu 316
题目中: Each shot always reduces the hit points of the target tank by 8, and if the number of hit points of the target before the shot was greater than zero, the shooting tank receives 3 score points.
sgu 178
f(n)表示问题的解 第一步:将n0 = n分成三部分a1 ,b1= 1, n1;其中a1 = n0 - n1 - 1,a1 〉= n1; n1 是之后要分解的 ,可行解为 f(n1) 我们得到 a1,b1, f(n1) 前n1天,用n1(会拆开)支付,解为f(n1)第n1+1天用 b1支付第n1+2天用a1(完整的)支付,必须找零a1 - 1,店主有n1+1个,所以必须有
sgu 224
//dfs // k = 0, ans = 1; // k = 1, ans = n*n ; // k > n, ans = 0; //还可以进一步优化 // if (n - ps < k - count) rollback; 当剩余列数小于剩余棋子数时,回滚 // 对称性优化, 第一个棋子放在某一列m行,和放在该列n-m+1 // 直接用数组保存所有结果 ---
sgu 226
/* notice: the graph may contain loops between two point,there may be many ways that have different color */ #include #include using namespace std; const int INF = 0x7ffffffe; int n, m; int
1万+



被折叠的 条评论
为什么被折叠?



