“美登杯”上海市高校大学生程序设计邀请赛

VCL for PHP,Konopka Signature VCL Controls (Raize Components 6.2.3) for Delphi 10.4 The Raize Components suite includes a variety of interface design tools for Delphi programming language and C ++ Builder, which includes over 125 VCL controls and over 100 different tools for creating... 阅读详情

这次比赛一半时间都是在车上做的,不过效果还行。

A. 小花梨的字符串

没想太多,看完样例,就是找的区间内子序列的个数,直接写,就过了很迷。才写了16行!!!

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,q;
    cin>>n>>q;
    char s[100005];
    cin>>s;
    while(q--)
    {
        int l,r;
        cin>>l>>r;
        int len=r-l+1;
        cout<<len*(len+1)/2<<endl;
    }
}

I. 小花梨点外卖

简单的一个外卖题,总价值满足哪个减哪个,两种满减都满足的话,就参与减的最多的。= =。对于经常点外卖的我还是很快的。

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b,c,d,x;
    int sum=0;
    cin>>n>>a>>b>>c>>d;
    while(n--)
    {
        cin>>x;
        sum+=x;
    }
    if(sum>=a&&sum<c)
    {
        cout<<sum-b<<endl;
    }
    else if(sum>=c&&sum<a)
    {
        cout<<sum-d<<endl;
    }
    else if(sum>=a&&sum>=c)
    {
        if(sum-b<sum-d)cout<<sum-b<<endl;
        else cout<<sum-d<<endl;
    }
    else cout<<sum<<endl;
    return 0;
}

D. 小花梨的取石子游戏

一道最简单的博弈问题。看谁能够掌控全局。如果每次游戏开始时,第一个不为1则F赢,如果第一个为1,第二个不为1,则S赢,如果第一个为1,第二个为1,第三个不为1,则F赢。所以说刚开头连续出现一个1就会进行反转。然后开始写,发现WA在了第7个测试用例,然后全部输入1时,发现错误了。特判一下,就过了。提示:算连续1时,应避免重复计算,否则会超时。

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,cnt=0;
    int a[200005];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        a[i+n]=a[i];
        if(a[i]==1)cnt++;
    }
    if(cnt==n)
    {
        if(n%2==1)
        for(int i=0;i<n;i++)cout<<"First"<<endl;
        else for(int i=0;i<n;i++)cout<<"Second"<<endl;
        return 0;
    }
    int tmp=0;
    for(int i=0;i<n;i++)
    {
        if(tmp==0)
        {
            for(int j=i;j<2*n;j++)
            {
                if(a[j]!=1)break;
                tmp++;
            }
            
        }
        if(a[i]==1)
        {
            if(tmp%2==0)cout<<"First"<<endl;
            else cout<<"Second"<<endl;
            tmp--;
        }
        else cout<<"First"<<endl;
    }
}

B. 小花梨的三角形

会判断一共有多少个三角形,你就已经赢了一半了。在输入样例中可以发现在一个正方形中,只有右上角和左下角可以组成三角形。接着循环找一下组合,然后判断一下该组合出没出现就行了。本题学会了一个小技巧,就是再判断某一个字符串出没出现过,可以用map<string,int>m来判断一下,这样的话可以省时间,导致我AC。

#include <bits/stdc++.h>
using namespace std;
int temp;
map<string,int>m;
char ans[4];
int main()
{
    int n,d,r,sum=0;
    char s[105][105];
    cin>>n;
    for(int i=0;i<=n;i++)cin>>s[i];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<strlen(s[i]);j++)
        {
            
            for(int k=i+1;k<=n;k++)
            {
                ans[0]=s[i][j];
                ans[1]=s[k][j];
                ans[2]=s[k][k-i+j];
                sort(ans,ans+3);
                if(!m[ans])
                {
                    m[ans]=1;
                    temp++;
                }
            }
        }
        for(int j=0;j<strlen(s[i])-1;j++)
        {
            for(int k=j+1;k<strlen(s[i]);k++)
            {
                if(i+k-j>n)break;
                ans[0]=s[i][j];
                ans[1]=s[i][k];
                ans[2]=s[i+k-j][k];
                sort(ans,ans+3);
                if(!m[ans])
                {
                    m[ans]=1;
                    temp++;
                }
            }
        }
    }
    cout<<temp<<endl;
    return 0;
}

 

机器人环境仿真软件:Webots_(9).路径规划与导航算法仿真实现 通过仿真,我们可以验证路径规划算法的有效性和鲁棒性,同时优化机器人在不同环境中的导航性能。动态窗口法是一种局部路径规划算法,通过在机器人当前速度空间中选择一个最优的速度窗口,使机器人在动态环境中安全地移动。算法的代价函数通常包括两个部分:从起始点到当前节点的实际代价(g-cost)和从当前节点到目标节点的估计代价(h-cost)。在World Editor中,选择“Insert”菜单,添加“Robot”对象,如“E-puck”或“Thymio”。Dijkstra算法的实现与A*算法类似,但不使用启发函数。 阅读详情

相关推荐

【Vite+Vue3+TS】基于Vite+Vue3+TypeScript+ESLint+Prettier+Stylelint搭建项目(亲测超详细)

结合了很多项目和文章,总结一篇项目构建的笔记。 温馨提示:文章末尾记录了我在搭建项目过程中,遇到的一些问题和解决办法 ~

aDiaoYa_的博客 4241

2023 年上海市大学生程序设计竞赛 - 五月赛 C

一开始想的是DP,然后想一下,其实可以一直摆,然后等到某一天不够的时候,放弃之前摆的能卷的尽量多的一天就行了,用一个最大堆。

m0_60921016的博客 239

蓝桥杯嵌入式(基础教程)STM32G431RBT6——创建工程以及点灯

首先选择正确的芯片类型:STM32G431RBT6工程的创建主要有配置时钟以及烧录的方式。在配置好之后需要对时钟进行配置,由于蓝桥杯的外部晶振是24MHz因此需要对时钟树进行相应的配置。第一步先点击时钟配置之后就可以对时钟进行相应的配置了最后一步,需要对工程起一个名字,并且要选择KEIL做为其相应的软件之后再需要再生成代码那里进行相应的控制。当然这样根据生成的工程不能直接使用会有一个报错,所以需要添加一个启动文件。这个启动文件可以在官方的LCD文件夹下复制到自己的工程中。

m0_74051113的博客 1093

2023 年上海市大学生程序设计竞赛 - 四月赛

23年8月27号写的,想想发了。

zy98zy998的博客 402

使用libx265对YUV进行h265编码

使用libx265对YUV进行h265编码

Embedded engineer 3088

通讯软件002——快速使用modscan进行modbus调试

快速使用modscan进行modbus调试

zhouwl72的博客 1040

2023 年上海市大学生程序设计竞赛 - 一月赛A题题解

2023 年上海市大学生程序设计竞赛 - 一月赛A题题解

技术栈:C++、go、python,方向:软开,测开 724

摄像头模组CCM简介

摄像头模组,全称Camera Compact Module,简写为CCM。CCM 包含几大件: 镜头(lens)、音圈马达(VCM)、传感器(sensor)、软板(FPC)、图像处理芯片(DSP)。工作原理:物体通过镜头(lens)聚集的光,通过CMOS或CCD集成电路,把光信号转换成电信号,再经过内部图像处理器(ISP)转换成数字图像信号输出到数字信号处理器(DSP)加工处理,转换成标准的GRB、YUV等格式图像信号。摄像头模组主要由以下几个部分组成:镜头(Lens):将光线汇聚到图像传感器上。

m0_73482095的博客 1万+

2022 年上海市大学生程序设计竞赛 个人题解

title : 2022 年上海市大学生程序设计竞赛 个人题解tags : ACM,题解。

SC_Linno的博客 2067

【数字图像相关-OpenCorr学习笔记】Epipolar search原理+代码解析

OpenCorr是一个开源C++库,用于研究和开发数字图像相关(DIC)技术它提供了2D和立体声DIC的全功能模块,以及数字体积相关(DVC)。最近正在学习OpenCorr,为了更深层次地理解ICGN,我打算浅浅剖析Opencorr的代码,学习的过程中写下这篇学习笔记,以后忘记了还能回来看看。同时,作为一名在读研究生,希望能得到社区大佬的指点,以及跟同学们一起学习进步。这一期主要讲解Eipipolar search的原理,并且附上部分代码解析。

ywyywyy的博客 1364

2022年全国职业院校技能大赛网络系统管理赛项模块A:网络构建(样题5)-网络部分解析-附详细代码

2022年全国职业院校技能大赛网络系统管理赛项模块A:网络构建(样题5)-网络部分解析-附详细代码

bfq05234214的博客 440

2020上海高校程序设计竞赛暨第18届上海大学程序设计联赛夏季赛(同步赛)

C.爵士 签到题 注意点:字符串读入空格用getline(cin,s),不需要高精度除法,double强制类型转换即可 ps:教训就是没看清题意直接做,题意是一句话只要有一个2就是二次元,cnt++,而不是cnt计算所有2,所以一个字符串遇到一个2以后就break,无需继续计算 #include<iostream> #include<cstring> #include<cstdio> #include<string> using namespace std;

fusu123456789的博客 328

如何从 VMware 官网下载最新版本的 VMware Workstation

如何从 VMware 官网下载 VMware Workstation

XiaoqiangClub的博客 6010

“美登杯”上海市高校大学生程序设计邀请赛补题

“美登杯”上海市高校大学生程序设计邀请赛补题 ### 传送门 A题 题目吓人,实际上就是求子串的个数。长度为n的字符串子串个数为(n+1)*n/2 #include<bits/stdc++.h> using namespace std; #define fin freopen("in.txt", "r", stdin) #define fout freopen("out.txt", "...

weixin_34096182的博客 157

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

深度学习工具包 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")

“美登杯”上海市高校大学生程序设计邀请赛 **D. 小花梨的取石子游戏**

“美登杯”上海市高校大学生程序设计邀请赛 (华东理工大学) D. 小花梨的取石子游戏 Description 小花梨有????堆石子,第????堆石子数量为????????,????堆石子顺时针编号为1 − ????(如图)。 游戏将进行 游戏将进行????轮, 轮, 每轮游戏 单独进行 ,互不干扰 ,每轮初始时第 每轮初始时第???? 堆石子数目为????????。 。 第????轮从编号为????的那堆石子为起点,顺时针来取石子。两人轮流取石子,不可不取...

weixin_30387663的博客 140

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

“美登杯”上海市高校大学生程序设计邀请赛 (华东理工大学)

“美登杯”上海市高校大学生程序设计邀请赛 (华东理工大学) I.小花梨点外卖(签到成功) 题目链接:https://acm.ecnu.edu.cn/contest/173/problem/I/ 题解:对两种优惠方案分别计算,取最小值 #include <bits/stdc++.h> #define P pair<int,int> #define fir first #def...

weixin_30414305的博客 253

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

质因数的性质(美登杯”上海市高校大学生程序设计邀请赛 (华东理工大学) E题)

分解一个在 N范围内 的数 的 质因数 我们首先想到的是把 N 范围内 的所有素数O(N)的筛选出来,然后while跑质数表,来达到加速查找的目的。 但是现在 我们可以发现 , 一个数X , 它的质因数 肯定在 sqrt(X)内是 最多的 令 Y = sqrt(X) , 假设 Y现在是一个质数 , 那么 后面明显就不会有 X的质因数 , 所以 我们进行分解质因数的时候,可以只筛...

我歌月徘徊,我舞影零乱 341

“美登杯”上海市高校大学生程序设计邀请赛(BCD解析链接)

B题 D题 C题

black_hole6的博客 392

“美登杯”上海市高校大学生程序设计邀请赛 (华东理工大学) C. 小花梨判连通

题目链接:https://acm.ecnu.edu.cn/contest/173/problem/C/ 题意: Description 小花梨给出

还我笑颜 404

“美登杯”上海市高校大学生程序设计邀请赛 (华东理工大学)C题 小花梨判连通

思路: 1.对于每个图用并查集对每个联通块染色 2.k次染色可以的得出每个点(1~n)的染色序列 3.如果i j两个点联通那么他们的染色序列相同,所以map所有染色序列即可 这里对序列排序使用的是自定义字典序排序,需要往map第三个参数传入一个类函数模板(不能是函数指针) /* 思路: 1.对于每个图用并查集对每个联通块染色 2.k次染色可以的得出每个点(1~n)的染色序列 3.如果i ...

Dch19990825的博客 259

“美登杯”上海市高校大学生程序设计邀请赛 (华东理工大学) 第二场比赛

比赛链接:https://acm.ecnu.edu.cn/contest/173 这次比赛A了4道题,因为SQL等课程的原因,做了3个多小时做不动就放弃了 Problem A、小花梨的字符串 第一眼以为防ak,过了5分钟看下榜,这么多人过,猜了一下答案应该是他的全部子串, 就这样过了 难度未知..... #include<bits/stdc++.h> #de...

Dch19990825的博客 347

“美登杯”上海市高校大学生程序设计邀请赛 (华东理工大学) - B. 小花梨的三角形

问题: https://acm.ecnu.edu.cn/contest/173/problem/B/ 算一下时间复杂度100层的三角形,边长为1的个数,是1+3+5+7+……+199,等差数列求和,是20000个,然后我们知道边长大于1的三角形个数都是要小于边长为1的三角形个数的,粗略地算一下,我们就知道2e4*100 = 2e6,然后我们就可以愉快地暴力了。 但是我们记录不同的时候,我们可以对它...

XYQ BLOG 192

美登杯”上海市高校大学生程序设计邀请赛 Problem E 、 小 花梨 的数组 (线段树)...

Problem E E 、 小 花梨 的数组 时间限制:1000ms 空间限制:512MB Description 小花梨得到了一个长度为????的数组????,现在要对它进行三种操作: ⚫ 1 ???? ] ∗ ⚫ 2 ???? ???? 对所有的???? ∈ [????,????],????[????] = ????[????] / ????????????????????????????????(????[????]) ⚫ 3 ???? 求????[????]的值 ??????????????????

weixin_30387663的博客 161
上一篇: Educational Codeforces Round 65 (Rated for Div. 2) May/15/2019
下一篇: 关于线段相交问题
codehappy123
博客等级 码龄8年 8粉丝 35原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值