Teams Formation CodeForces - 878B (思维+模拟)

MATLAB项目,模拟曲柄滑块机构的运动学和动力学.zip 1.版本:matlab2014a/2019b/2024b 2.附赠案例数据可直接运行。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。 立即下载

Teams Formation

CodeForces - 878B

This time the Berland Team Olympiad in Informatics is held in a remote city that can only be reached by one small bus. Bus has n passenger seats, seat i can be occupied only by a participant from the city ai.

Today the bus has completed m trips, each time bringing n participants. The participants were then aligned in one line in the order they arrived, with people from the same bus standing in the order of their seats (i. e. if we write down the cities where the participants came from, we get the sequence a1, a2, ..., an repeated m times).

After that some teams were formed, each consisting of k participants form the same city standing next to each other in the line. Once formed, teams left the line. The teams were formed until there were no k neighboring participants from the same city.

Help the organizers determine how many participants have left in the line after that process ended. We can prove that answer doesn't depend on the order in which teams were selected.


Input

The first line contains three integers n, k and m (1 ≤ n ≤ 105, 2 ≤ k ≤ 109, 1 ≤ m ≤ 109).

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 105), where ai is the number of city, person from which must take seat i in the bus.

Output

Output the number of remaining participants in the line.

Examples
Input
4 2 5
1 2 3 1
Output
12
Input
1 9 10
1
Output
1
Input
3 2 10
1 2 1
Output
0
Note

In the second example, the line consists of ten participants from the same city. Nine of them will form a team. At the end, only one participant will stay in the line.

题意:

给出一个长为n的序列,将其重复m次,连续相等的k的个元素可以被消除,问最后剩余多少个元素。

思路:

这道题我是看的网上的博客,看了半天终于看明白了,所以这里我就按照那篇博客的思路具体解释一下

首先我们先考虑单个串,如果单个串中有恰好k的倍数个连续相同字符,那么我们应该先将其消除,那么第一步我们遍历数组,这里我们需要用到一个pair数组,这个数组是整道题目的关键,pari数组中前面存数值,后面存个数,这样如果我们遍历到的数字和前一个相同也就是找到了连续相同的,我们只需要给顶部的元素的st[top].second+1,如果发现和前一个元素不同说明已经不连续相同了,这时候我们再把这个数放进去,这样的好处就是我们pair数组中用一个数字和其个数代表了连续相等的串,这样我们只需要判断st[i].second%k是否等于0就可以。这样对于初始串的处理就结束了,我们就得到的消去连续的后的单个串的个数我们记为rec

然后我们观察,发现对于每两个串相连,其实就是一个串的首尾相连把连续相同的k个消去,这样我们还是对一个串处理,我们继续处理pair数组,用两个下标l,r从两边向中间缩,如果两头数字相同并且,他们的个数之和恰好是k的倍数,那么这一堆全都可以消去,这样我们让l++,r++,记录下消除的个数,一直到两头数字不能完全消除为止,用while循环实现,每个串消除的首尾总个数我们记为rec2,同时我们发现第一个串的首和最后一个串尾可能不会接触,那么我们可以确定一定会减去m-1个rec2

如1 1 3 2 1 k = 3三个相连 1 1 3 2 1 1 1 3 2 1 1 1 3 2 1消除两个的,两头的暂时不会接触

此时循环结束后会有两种大情况

一、只剩下了一种数字

(不是一个,因为这一种数字可能多个,注意pari数组的意义)

二、剩下多种数字

对于第一种,因为每种数字都属于一个串也就是有m个,因此又分成两种情况:

1、总共m*每种的个数如果是k的倍数,直接全部消去,并且要十分注意,中间都消除了,那么这是首尾就有碰面了,这样又得消除一个rec2,一共就消除了m个rec2

如串1 1 3 1 , k = 3,三个相连 1 1 3 1 1 1 3 1 1 1 3 1

先消去了111,然后得到了 1 1 3 3 3 1,然后就可以消去3然后就到了 1 1 1,就可以消去1了,首尾碰面了。

2、另一种当然就是不能被k整除,那么我们就只能减去k的倍数的个数

还是串1 1 3 1 k = 3,四个相连1 1 3 1 1 1 3 1 1 1 3 1 1 1 3 1

得到1 1 3 3 3 3 1,这个时候中间的3只能消去3个(3的1倍)得到1 1 3 1

对于第二种,

1、如果首尾数字相同,说明他们总数不是k的倍数,但是我们还是要减去小于它的k的倍数

2、如果不同那么就直接减掉我们之前统计的消掉的就好了

注意用long long

code:

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
const int maxn = 1e5+10;
ll a[maxn];
pair<ll,ll> st[maxn];
ll top,n,m,k,l,r,rec,rec2;
ll ans;
int main(){
    cin >> n >> k >> m;
    for(ll i = 1; i <= n; i++)
        cin >> a[i];
    for(ll i = 1; i <= n; i++){
        if(!top || st[top].first != a[i])
            st[++top] = make_pair(a[i],1);
        else
            st[top].second = (st[top].second + 1) % k;
        if(st[top].second == 0) top--;
    }
    for(ll i = 1; i <= top; i++){
        rec += st[i].second;
    }
    l = 1,r = top;
    while(l < r && st[l].first == st[r].first && (st[l].second + st[r].second) % k == 0){
        rec2 += st[l].second + st[r].second;
        l++;
        r--;
    }
    if(l == r){
        if(st[l].second * m % k == 0)
            ans -= rec2;
        ans += m * rec - rec2 * (m - 1) - (st[l].second * m / k * k);
    }
    else{
        if(st[l].first == st[r].first)
            rec2 += (st[l].second + st[r].second) / k * k;
        ans = m * rec - rec2 * (m - 1);
    }
    cout << ans << endl;
    return 0;
}


基于MATLAB的Abel反演和Fowler–Milne诊断研究对HyperFill TWGMAW-P进行了电波形分析。.zip 1.版本:matlab2014a/2019b/2024b 2.附赠案例数据可直接运行。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。 立即下载

相关推荐

aerosonde-fc-hybrid-uav-sim-main.zip

1.版本:matlab2014a/2019b/2024b 2.附赠案例数据可直接运行。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。

codeforces 878B B. Teams Formation 模拟

B. Teams Formation time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output This time the Berland Team Olympiad in I

SUNSET 802

增强型PID-自适应-前馈-神经网络控制研究(Matlab代码实现)

内容概要:本文系统研究了“增强型PID-自适应-前馈-神经网络控制”复合控制策略,结合Matlab代码与Simulink仿真模型,深入探讨了传统PID控制与智能控制算法的深度融合方法。该策略通过引入自适应机制和前馈补偿,结合BP神经网络进行非线性系统建模与参数优化,并融合扩展卡尔曼滤波(EKF)等状态估计技术,提升控制系统在复杂动态环境下的响应速度、鲁棒性和控制精度。研究涵盖双闭环控制架构设计、神经网络训练流程、EKF状态融合等关键技术环节,适用于电机控制、电力电子变换器、无人机、微电网等高阶非线性系统的建模与仿真。配套资源丰富,包含多个可复现的Simulink模型、Matlab代码及参考文献,尤其支持高水平EI期刊成果的复现与验证。; 适合人群:具备自动控制理论基础和Matlab/Simulink仿真能力,从事控制工程、电气自动化、电力电子或智能系统研发的研究生、科研人员及工作1-3年以上的工程技术人员; 使用场景及目标:①深入研究先进PID控制策略在非线性系统中的优化应用;②实现神经网络与经典控制算法的协同设计与联合仿真;③开展状态估计、参数辨识与智能控制策略的实验验证;④复现并拓展高水平学术论文中的控制方法,支撑科研创新与项目开发; 阅读建议:建议结合提供的Matlab代码与Simulink仿真模型进行实践操作,重点剖析控制结构设计逻辑、神经网络训练过程及EKF状态估计的实现细节,按照文档说明逐步调试与优化,以全面掌握复合控制系统的建模、仿真与性能评估方法。

codeforces D.Teams Formation

转载:http://www.cnblogs.com/TnT2333333/p/7742730.html #include #include #include #include #include #define INF 99999999 #define maxn 100005 #define LL long long using namespace std; struct node { int

wwwlps的博客 260

【带状电容器计算用于电容式触摸传感器应用】半数值模型的电容式触摸传感器集成于金属基材涂层中研究(Matlab代码实现)

内容概要:本文针对集成于金属基材涂层中的电容式触摸传感器,提出了一种用于带状电容器电容计算的半数值模型,并基于Matlab平台实现了仿真分析。该模型结合解析方法与数值计算,采用有限差分法求解二维泊松方程,精确模拟传感器在金属背景下的电场分布,有效克服了金属基底对电容信号的屏蔽与干扰问题,显著提升了触摸检测的灵敏度与稳定性。研究系统探讨了传感器的几何结构、介电层材料特性、电极尺寸及间距等关键参数对电容响应的影响机制,建立了完整的建模流程与仿真框架,为高性能、高抗干扰能力的电容式触控器件在智能家居、工业控制面板及复杂电磁环境下的实际应用提供了理论支撑与技术路径。; 适合人群:具备电磁场与电磁波、数值计算方法基础,熟悉Matlab编程,从事传感器设计、人机交互技术开发、电子器件仿真及相关领域研究的科研人员、工程师及研究生。; 使用场景及目标:①面向金属表面集成的电容式触摸传感器进行高精度建模与性能优化;②为智能家电、工业设备等人机接口的触控模块提供抗干扰设计与仿真验证方案;③支撑相关科研课题的理论分析、算法开发与原型系统验证。; 阅读建议:学习者应结合提供的Matlab代码深入理解半数值建模的具体实现过程,重点掌握有限差分法在电场求解中的应用技巧,并可通过调整传感器结构参数与材料属性开展对比仿真,进而探究各因素对灵敏度的影响规律,全面提升对电容式传感机制的理解与工程化设计能力。

免费搞定DWG转DXF:ODA File Converter保姆级配置指南(附常见报错解决)

本文详细介绍了如何使用ODA File Converter免费工具实现DWG到DXF的格式转换,包括环境配置、命令行参数解析、编程集成方案及常见问题解决。特别针对网络访问异常、参数配置等实际痛点提供应对策略,帮助用户高效完成工程设计文件的格式转换。

weixin_29291185的博客 5985

Teams Formation CodeForces - 878B

Teams Formation 题目链接:CodeForces - 878B题意:给出有n个数的序列, 将该序列重复m次, 如果有k个连续的相同的数, 去掉这k个数, 直到没有连续的相同的k个数为止, 问最后还有几个数?首先, 我们先把原序列...

Sirius_han的博客 259

专栏丨华为HN8145XR光猫获取超级管理员密码

摘要:本文详细介绍了华为HN8145xr光猫获取超级管理员权限的完整步骤。首先通过ONT使能工具补全shell,然后利用Telnet登录光猫后台进行操作。文章提供了多种获取超级密码的方法,包括配置文件解密、一键查询工具等,并针对联通光猫特别说明了默认密码格式(CUAdmin+后八位数字)。此外,还介绍了恢复出厂设置、修改SSID等实用操作,帮助用户完全掌控光猫设备。文末附有详细的命令行操作指南,适合有一定技术基础的用户参考。

8247

cf878B. Teams Formation

分析、特判

ACoder 301

陷波滤波器设计以及Simulink仿真

离散型陷波滤波器设计以及simulink仿真

hmq252198885的博客 3164

数据库迁移策略实战:MySQL到PostgreSQL

数据库迁移是一项复杂且细致的任务,需要充分的准备工作、合适的迁移策略和严格的验证与优化步骤。通过选择合适的迁移工具、进行手动迁移和应用程序适配、以及迁移后的验证与优化,可以确保数据迁移的成功和业务的连续性。希望本文的分享能够为大家在MySQL到PostgreSQL的数据库迁移实战中提供一些有用的参考和启示。

shejizuopin的博客 1730

Codeforces Round #443 (Div. 1) B. Teams Formation

B. Teams Formation link http://codeforces.com/contest/878/problem/B describe This time the Berland Team Olympiad in Informatics is held in a remote city that can only be reached by one small bus. Bus ...

weixin_34290000的博客 77

嵌入式八股文-ARM

嵌入式八股文总结(ARM篇)-优快云博客现象:I2C死锁就是时钟线SCL一直处于高电平,数据线SDA一直处于低电平。从机拉低数据线SDA时(发送应答信号给主机时或发送数据0时)主机意外复位,主机复位后时钟线SCL就为高电平了,此时,SCL为高电平而SDA为低电平,主机就以为有其他设备占有了总线,而SCL为高电平时 数据位SDA不允许有变化,意思是:主机就一直等待时钟线SDA拉高,而从机就一直等待时钟线SCL拉高 就造成了死锁的现象。解决方法:1.选择带有复位功能的从设备,复位后SDA被拉高。

m0_63127436的博客 1257

443 D. Teams Formation

http://codeforces.com/contest/879/problem/D This time the Berland Team Olympiad in Informatics is held in a remote city that can only be reached by one small bus. Bus hasnpassenger seats, se...

weixin_30347009的博客 140

kettle多表数据迁移

点击 文件——新建——作业,在左侧的 核心对象 标签下选择 通用,双击添加一个 start ,一个 转换 ,一个 作业 和一个 成功 到右侧的作业面板,这些作业项都可以改名字。点击文件—新建—转换,在左侧的 核心对象 标签下选择 输入 下的 表输入,双击添加到右侧的转换面板,再选择 作业 下的 复制记录到结果 ,双击添加到右侧的转换面板。新建转换,在左侧的 核心对象 标签下选择 作业 下的 从结果获取记录,双击添加到右侧的转换面板,再选择 作业 下的 设置变量 ,双击添加到右侧的转换面板。

u014061745的博客 1340

机器人中的数值优化(十二)——带约束优化问题简介、LP线性规划

本系列文章主要是我在学习《数值优化》过程中的一些笔记和相关思考,主要的学习资料是深蓝学院的课程《机器人中的数值优化》和高立编著的《数值最优化方法》等,本系列文章篇数较多,不定期更新,上半部分介绍无约束优化,下半部分介绍带约束的优化,中间会穿插一些路径规划方面的应用实例

慕羽★的博客 3850

Codeforces Round #443 (Div. 2) D. Teams Formation

D. Teams Formation time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output This time the Berland Team Olympiad in Informatics is held in a remote

zstu_zy的博客 266

基于深度学习YOLOv5的草莓成熟度检测系统详解(深度学习模型+UI界面+Python代码+训练数据集)

数据采集与预处理模块:负责收集草莓图像,并进行数据增强和标注。深度学习模型训练模块:使用YOLOv5模型进行草莓成熟度检测模型的训练。模型推理模块:加载训练好的模型,对输入图像或视频进行草莓成熟度检测。UI界面模块:提供用户交互界面,方便用户上传图像或视频进行成熟度检测。本文详细介绍了基于YOLOv5的草莓成熟度检测系统的构建过程,包括数据集的构建、模型的训练与推理、以及UI界面的设计。通过本文的指导,读者可以快速搭建一个高效的草莓成熟度检测系统,并应用于实际场景中。

斌擎科技 523

Team Formation

For an upcoming programming contest, Edward, the headmaster of Marjar University, is forming a two-man team fromNstudents of his university. Edward knows the skill level of each student. He has fou...

WhileTrue 299

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

CF878B Teams Formation

#include   #include   #include #include #include   #include   #include   #include   #include   #include   #include   #include   #include   #include   #include   #include

u011535421的博客 491

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

cf 443 D. Teams Formation](细节模拟题)

cf 443 D. Teams Formation(细节模拟题) 题意: 给出一个长为\(n\)的序列,重复\(m\)次形成一个新的序列,动态消除所有k个连续相同的数字,问最后会剩下多少个数(题目保证消除的顺序对答案不会造成影响) \(n <= 10^{5} ,m <= 10^{9} ,k <= 10^{9},a_i <= 10^{5}\) 思路: 直接上题解好了 首先要用...

weixin_33709609的博客 164

深度学习工具包 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');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Teams Formation

题意: 给定一长度为 n 的整数序列 $a$,将其复制m次,并接成一条链,每相邻K个相同的整数会消除,然后其他的整数继续结成一条链,直到不能消除为止,求问最终剩余多少个整数。 解法: 首先将长度为n的序列消干净,然后接下来的消除操作必然是在两个序列相交处进行消除,对于接在中间的序列,原消法等价于序列的左侧和右侧不停消除直到无法继续。 分类讨论: 1.序列左右消干净了,这样答案为0 ...

weixin_30820077的博客 140

CodeFroce 879D Teams Formation 暴力瞎搞

D. Teams Formation time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output This time the Berland Team Olympiad in Informati...

weixin_34320159的博客 191
上一篇: Superbot ZOJ - 3865 (BFS)
下一篇: Table Tennis CodeForces - 879B (思维+模拟)
Guuuuuu老师儿
博客等级 码龄9年 259粉丝 718原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值