Educational Codeforces Round 124 (Rated for Div. 2)ABCD题解

Unity中URP实现水体效果(泡沫) 在上篇文章中,我们实现了水体的深度。在这篇文章中,我们来使用上篇文章采样后的深度图来实现水中的泡沫效果。 阅读详情

A. Playoff

传送门
在这里插入图片描述
题目大意:输入一个整数n,就有2n个人进行分组比赛,第一轮:12一组,34一组,…,2n-1和2n一组,当一组内编号连续则胜者为编号小的那个,否则胜者为编号高的那个。
解题思路:很明显最后胜者始终为最大的奇数即2n-1

输入样例

2
3
1

输出样例

7
1
#include <iostream>

using namespace std;
typedef long long ll;
const int N = 31;
ll a[N];
int main()
{
    int t;
    cin >> t;
    a[0] = 1;
    for(int i = 1 ; i < N ; i++){
        a[i] = a[i - 1] * 2;
    }
    while(t--){
        int n;
        cin >> n;
        cout << a[n] - 1 << endl;
    }
    return 0;
}

B. Prove Him Wrong

传送门
在这里插入图片描述
输入样例

3
2
512
3

输入样例

YES
1 337
NO
YES
31 4 159

在这里插入图片描述
题目大意:对于一个长度为n的数组a,一定能找到两个下标i,j,令a[i]=a[j]=|a[i]-a[j]|,数组a的总和会减少,我们要证明这个结论是错误的。输入一个n为数组的长度,如果有一个数组a,a中的元素不能大于1e9,进行任意这样的操作最后数组a的总和增加或不变,就输出数组a,否则输出NO。
解题思路:将题目的意思转换为不等式即我们要找到一个a[i],a[j]使得:
a[i]+a[j] <= 2 * |a[i]-a[j]| =>
a[i]+a[j] <= 2 * a[j] - 2 * a[i] =>
3a[i] <= a[j] =>
a[i] <= 1/3 * a[j]
所以第二个数只要是第一个数的3倍及以上,那么二者差值的2倍一定大于二者之和,那么我们就可以得到一个序列1 3 9 27 … 直到大于1e9,如果遇到第一个a[m] > 1e9那么输入的n如果大于等于m就输出No,否则输出Yes,所以我们需要先预处理一下

#include <iostream>
using namespace std;
const int N = 1002;
typedef long long ll;
ll a[N];
int main()
{
    int t;
    cin >> t;
    a[1] = 1;
    int flag = 0;
    for(int i = 2 ; i < 1002 ; i++ ){
        if(!flag){
            a[i] = a[i - 1] * 3;
        }
        if(a[i] * 3 > 1e9 && !flag){
            flag = i;
        }
    }
    while(t--){
        int n;
        cin >> n;
        if(n > flag){
            cout << "NO";
        }else{
            cout << "YES" << endl;
            for(int i = 1 ; i <= n ; i++){
                cout << a[i] << " ";
            }
        }
        cout << endl;
    }
    return 0;
}

C. Fault-tolerant Network

传送门
在这里插入图片描述
输入样例

2
3
1 10 1
20 4 25
4
1 1 1 1
1000000000 1000000000 1000000000 1000000000

输出样例

31
1999999998

题目大意:有两排电脑,每排电脑的个数为n,每排的电脑网络都是互通的(假设第一排的电脑为数组a,第二排为数组b),如a1连接a2,a2连接a3,…,an-1连接an,b也是一样。但是ab互不连通,现在需要你将a和b连接起来,每次连接都会花掉|ai-bj|,并保证a和b任意一台电脑挂掉了,a和b的网络连接不会断也不会出现某台电脑被孤立同时花费最小。

解题思路:通过分析我们可以知道,边界电脑a1,an,b1,bn必须被连接,如果a1没有被连接,那么假设a2挂掉了,a1就会成为孤立的点,同时我们也只需要让这四个点被连接,这样无论哪个的电脑挂掉都能保证两排电脑的每两个都能互通。可以抽象成一个矩形,如果有条边断掉,也还是一根线,不会断成两根线。
那么如何保证这四个点都被连接并且花费最小呢,这就需要枚举了。首先对于a1,有三种连接情况:b1,bn,bi:min(|a1-bi|)(i>1&i<n),b1、bn、an的情况也一样。我们只需要将这些情况枚举,找到最小的花费即可。

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
const int N = 1e6;
#define Inf 1e9
typedef long long ll;
bool vis[N];
ll ans;
int cal(vector<ll> &v,int cur){ //寻找与该数组元素的最小差值
    ll res = 1e9;
    int pos;
    for(int i = 0 ; i < v.size() ; i++){
        if(res > abs(v[i] - cur)){
            res = abs(v[i] - cur);
            pos = i;
        }
    }
    return pos;
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--){
        vector<ll>a,b;
        ans = 10ll * Inf;
        int n;
        scanf("%d",&n);
        ll x;
        for(int i = 1 ; i <= n ; i++){
            scanf("%lld",&x);
            a.push_back(x);
        }
        for(int i = 1 ; i <= n ; i++){
            scanf("%lld",&x);
            b.push_back(x);
        }
        vector<int> pos1 = {0, cal(b,a[0]), n-1};
        vector<int> pos2 = {0, cal(b,a[n-1]), n-1};
        for(auto i : pos1){
            for(auto j : pos2){
                ll res = abs(a[0] - b[i]) + abs(a[n - 1] - b[j]);
                if(i > 0 && j > 0){ // 如果a0没有连接b0
                    res += abs(b[0] -a[cal(a,b[0])]);
                }
                if(i < n -1 && j < n - 1){ // 如果an-1没有连接bn-1
                    res += abs(b[n - 1] - a[cal(a,b[n - 1])]);
                }
                ans = min(ans,res);
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}

D. Nearest Excluded Points

传送门
在这里插入图片描述
输入样例1

6
2 2
1 2
2 1
3 2
2 3
5 5

输出样例1

1 1
1 1
2 0
3 1
2 4
5 4

输入样例2

8
4 4
2 4
2 2
2 3
1 4
4 2
1 3
3 3

输出样例2

8
4 4
2 4
2 2
2 3
1 4
4 2
1 3
3 3

题目大意:给你一个点集,对于每个点输出不在点集内并且距离该点曼哈顿距离最近的点,曼哈顿距离distance = |x1-x2|+|y1-y2|
解题思路:采用bfs,首先遍历点集,对于一个点(x,y),曼哈顿距离最近为1,那么就遍历该点四个方向的点,如果找到一个点不在点集内就将(x,y)加入队列然后break。如果一个点四个方向的点都在点集内,那么与它曼哈顿距离最近的就是它四个方向中的点中曼哈顿距离最近的,可能有点绕,你可以想象假设一个点,他四个方向的点都在点集内,那么曼哈顿距离最近的点就变成外围点中曼哈顿距离最近的点,那么这个曼哈顿距离就变成2,因为曼哈顿距离为1的点都不能取。最后遍历整个队列,相当于这个队列的初始值就是整个图中最外围的点,那么里面的点就迭代更新为外围曼哈顿距离最近的点的答案。里面的点的答案就是外围点的答案。不停地迭代,最终每个点曼哈顿距离最近且不再点集内的答案就出来了。

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
using namespace std;
const int N = 1e6 + 100;
vector<int> g[N];
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
typedef pair<int,int> PII;
int main()
{
    int n;
    cin >> n;
    vector<PII> a(n);
    for(auto &[x,y] : a){
        cin >> x >> y;
    }
    set<PII> st(a.begin(),a.end());
    map<PII,PII> ans;
    queue<PII> q;
    for(auto [x,y] : a){
        for(int i = 0 ; i <4 ; i++){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(st.count({nx,ny})){
                continue;
            }
            ans[{x,y}] = {nx,ny};
            q.push({x,y});
            break;
        }
    }
    while(!q.empty()){
        int x = q.front().first;
        int y = q.front().second;
        q.pop();
        for(int i = 0 ; i < 4 ; i++){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(!st.count({nx,ny}) || ans.count({nx,ny})){ //如果该点不是点集内的点或者已经找到该点的答案就不加入该点
                continue;
            }
            ans[{nx,ny}] = ans[{x,y}];
            q.push({nx,ny});
        }
    }
    for(auto [x,y] : a){
        auto i = ans[{x,y}];
        cout << i.first << " " << i.second << endl;
    }
    return 0;
}

Global Mapper与ArcGIS双剑合璧:自动化与半自动矢量化提取地物轮廓实战 本文详细介绍了如何结合Global Mapper的自动化批量提取与ArcGIS的半自动精细修整功能,高效完成地物轮廓矢量化工作。通过实战案例,阐述了利用Global Mapper快速抓取初步轮廓,再借助ArcGIS的ArcScan等工具进行精细化编辑和优化的完整工作流,有效提升地理信息数据处理效率。 阅读详情

相关推荐

Cocos2d-x手游逆向实战:Frida高阶Hook与动态解密技术

Cocos2d-x作为主流跨平台游戏引擎,其混合架构(C++核心+JNI桥接+Lua/JS脚本)和强加固策略(符号剥离、anti-frida、so加壳)使传统逆向方法失效。本文围绕‘无符号定位’‘C++函数硬编码地址识别’‘Lua层AST级劫持’‘OpenGL内存回溯解密’四大关键技术展开,深入解析如何在真实上线项目中稳定hook被strip的libcocos2d.so关键函数、绕过反调试心跳检测、从glTexImage2D参数逆向追踪明文资源,并结合熵值扫描实现零先验知识的内存明文发现。面向已掌握Frid

weixin_30345577的博客 675

Educational Codeforces Round 124 (Rated for Div. 2)

日常倒序 C.Fault-tolerant Network 题意分析: 有两排电脑, 每一排的电脑是左右互连的,现在要求你将上下两排的电脑连接起来, 形成容错网络: 即网络保持连接,尽管其中一台计算机出现故障。换句话说,如果一台计算机坏了(不管是哪台),网络就不会分裂成两个或多个部分。连接两台计算机的费用是 ∣ai−bj∣|a_i - b_j|∣ai​−bj​∣ 首先形成容错网络, 连四条边 是肯定可以的, 但不一定是最优的, 也可以连两条边, 也可以连三条边 #include<bits/std

CPP2021的博客 463

三菱A800变频器矢量控制实战:从速度控制到位置控制的PLG参数设置全解析

本文深入解析了三菱A800变频器结合FR-A8AP选件板与PLG(脉冲编码器)实现高精度矢量控制的实战应用。详细阐述了从速度控制、转矩控制到位置控制三种高级模式的切换逻辑、核心参数设置及硬件接线要点,帮助工程师充分发挥A800变频器的闭环控制潜力,应对复杂工业自动化场景。

weixin_28308325的博客 327

Educational Codeforces Round 124 (Rated for Div. 2)C. Fault-tolerant Network

原题链接Problem - C - Codeforces 题意就是两边各有电脑,每边的电脑互相之间已经连接,在破坏一台电脑的情况下还要两边可以连接成功的最小代价是 代价=abs(a[i]-b[k]); 不难猜到只要两边两端的电脑可以连接到对面就一定可以,因为可以互相之间相互连,所以最少两条线最多四条线就可以了,先预处理一下两边两端相连的代价然后就可以去比较到底用几条线好了; 代码 #include<iostream> #include<algorithm> using n

qq_62165099的博客 347

网络流量监测技术

NetFlow是Cisco公司提出的网络数据包交换技术,该技术首先被用于网络设备对数据交换进行加速,并可同步实现对高速转发的IP数据流(Flow)进行测量和统计。  随着宽带互联网在中国 的迅速发展,全国各大电信运营商的网络规模都在不断扩张,网络结构日渐复杂,网络业务日趋丰富,网络流量高速增长。电信运营商需要通过可靠、有效的网络业 务流量监测系统对其网络以及网络所承载的各类业务进行及时、准

红杉树(ecitnet)的博客 5540

【花雕学编程】Arduino动手做(249)---ESP32+GC9A01之播放GIF的空战锁定动画

摘要: 本实验基于ESP32开发板,驱动1.28寸圆形IPS彩色TFT显示屏(GC9A01驱动,240×240分辨率),通过SPI接口实现GIF动画播放。利用TFT_eSPI和AnimatedGIF库,成功加载并循环播放预置的科幻风格GIF动画(如HUD界面、X翼战机等)。代码实现了GIF解码、逐帧渲染及动态显示功能,通过串口调试监控运行状态。实验验证了该显示屏在动态图像显示中的流畅性,为嵌入式图形应用提供了实用方案,适用于智能穿戴、交互设备等场景。 关键词: ESP32、GC9A01、圆形TFT、GIF播

雕爷学编程 492

Educational Codeforces Round 124 (Rated for Div. 2)(A-C)

A. Playoff 题意: 告诉你会执行2的n次方次比赛,参赛选手的标号也从1~2的n次方,两两pk,如果二者编号和是偶数,那么编号大的获胜进入下一轮,否则是奇数小的进入下一轮 思路: 不难发现,第一轮时每一组偏小的都会获胜也就是奇数会获胜,而进入到第二轮全是奇数,那么他们的和全是偶数,之后也是如此,因为偶数都被淘汰了,所以都会是出现奇数pk奇数的情况,所以输出最大的奇数即可,也就是2^n-1; #include<bits/stdc++.h> using namesp.

RIPKEY的博客 719

js逆向实战:爬取淘宝男装商品

本文介绍了一个淘宝商品数据爬取程序的技术实现方案。该程序通过分析淘宝H5页面接口,实现了商品名称、价格、销量等关键信息的抓取,并支持图片下载功能。核心内容包括:1. 使用Request库发送HTTP请求获取数据;2. 通过逆向分析淘宝的签名算法(MD5加密)生成合法请求;3. 解析JSON数据并提取商品信息;4. 处理分页参数实现多页数据爬取;5. 将数据保存为CSV文件并下载商品图片。程序还实现了反爬虫绕过、错误处理、文件管理等辅助功能,完整展示了从数据采集到存储的全过程。

那些看似不起波澜的日复一日,会在某天让你看到坚持的意义 1574

Educational Codeforces Round 124 (Rated for Div. 2)简训

Educational Codeforces Round 124 (Rated for Div. 2)简训 涉及的知识点:搜索,思维

C_eeking的博客 1120

【Windows Server 2019】活动目录 (Active Directory) ——理论

博文介绍了活动目录 (Active Directory) 的定义,作用以及与 DNS 的关系。同时也介绍了AD的组织结构,包括域控制器,子域,对象,属性,容器,组织单位,域间信任等术语的解释,实验拓扑图。

VMware, Windows, Linux, Cisco, Container, Kubernetes, Kali 7747

SAP ABAP 获取采购订单未清数量/在途库存的 6 种方式

这篇文章我总结了获取采购订单未清数量/在途库存的 6 种方式,每种方式的优劣势和适用场景有所不同。读者请结合自身需要选择。

SAP李斌,本人承诺所有原创文章均不使用任何AI生成技术,请大家放心阅读。 2667

Educational Codeforces Round 134 (Rated for Div. 2) A-D

ddl

weixin_45453817的博客 512

SAP公司间STO业务解析(包含主数据解析、后台配置解析、前台业务演示)

SAP公司间STO业务解析

ww114784的博客 1019

Educational Codeforces Round 124 (Rated for Div. 2)(ABCD)

Educational Codeforces Round 124 (Rated for Div. 2)(ABCD) 总结:日常犯病,细节处理不好 A. Playoff 题意:给定数字n,有2n2^n2n个人进行比赛,按顺序排好,每次两两比赛,如果两者和相加为奇数,则数字较小的晋级;否则数字较大的晋级。 思路:根据样例盲猜答案是2n−12^n-12n−1,幸运水过 #include<bits/stdc++.h> using namespace std; typedef long long ll;

一只大菜鸡的博客 522

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

Educational Codeforces Round 95 (Rated for Div. 2)解题报告

Educational Codeforces Round 95 (Rated for Div. 2) A. Buying Torches 题目大意 111根棍子能换xxx根棍子,yyy根棍子能换一份煤,111根棍子和111份煤能组成一根火柴,初始时你只有一根棍子,问你最少最多少次交换可以获得kkk根火柴 解题思路 根据题目意思,我们至少要有kkk块煤,那么就需要kykyky根棍子,还需要另外的kkk根棍子与其组成kkk根火柴,设aaa为用棍子换棍子的次数,bbb表示用棍子换煤块的次数,则有: a(x−1)+

weixin_44211980的博客 302

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

【Educational Codeforces Round 120 (Rated for Div. 2)】【题解A-C】

2021-12-28 文章目录2021-12-28A. Construct a Rectangle题目大意:测试样例:【code】:B. Berland Music题目大意:测试样例:【code】:C. Set or Decrease题目大意:测试样例:【code】: A. Construct a Rectangle 题目大意: 有三个长度为 l1、l2 和 l3 的整数棒。 你被要求将它们中的一个准确地分成两部分,这样: 两个部分都具有正(严格大于 0)整数长度; 碎片的总长度等于木棒的原始长度; 可以从

eternity_memory的博客 1200

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

Educational Codeforces Round 124 (Rated for Div. 2) -B-C

原题链接https://codeforces.com/contest/1651/problem/B 解题思路: 读题,题目要求对于任意的i,j做了ai=aj=|ai-aj|操作后都不会减小。 一: 满足不会减小这个条件。有a+b>=2*(a-b)(假设a是大的数) 则解方程有a>=3*b。 二: 由一即可发现数字序列必然是递增的(要满足题目条件,较大的数必须大于或等于另一数的三倍),所以要使序列最长即从最小数1开始列举。 三: 按此序列可以最长。1 3 9 27 81…(下一个数恰好是前一个的三

qq_52930538的博客 316

Educational Codeforces Round 99 (Rated for Div. 2) 题解

题目链接:Educational Codeforces Round 99 (Rated for Div. 2) A. Strange Functions 转换题意就是判断字符串长度 int main() { int n; cin >> n; while(n--) { string s; cin >> s; cout << s.length() << endl; } } B. Jumps int main() { int t; sc

张小生的先生的博客 392

Educational Codeforces Round 124 (Rated for Div. 2) (A-D题解)

源代码:ACM/OpenjudgeNow/Codeforces at master · abmcar/ACM (github.com) 更好的阅读体验: 折跃坐标 A. Playoff 题目大意: 思路: 比较简单的数学思路 我们发现每轮会刷掉奇数位的选手 不难发现和证明 最终剩下的一定是$2^n-1 $ 代码: void solution() { cin >> n; cout << (1 << n) - 1 << endl; } B. P

Abmcar的博客 1326

Codeforces1651-Educational Codeforces Round 124 (Rated for Div. 2)-题解(A-D)

比赛链接 A 题意 2n2^n2n名运动员比赛,当运动员 x 和 y 比赛时,获胜者的决定如下: 如果 x+yx+yx+y是奇数,则编号较低的运动员获胜 如果 x+yx+yx+y是偶数,则编号较高的运动员获胜。 思路 最后肯定是最大的奇数获胜,也就是2n−12^n - 12n−1 AC代码 #include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_wit

千淘万漉虽辛苦,吹尽狂沙始到金 1376

Educational Codeforces Round 90 (Rated for Div. 2)部分题解

A - Donut Shops 题解: 1.我们首先特判一下包装盒里面只有一个物品的情况,如果只装了一个物品,那我们就直接比较这两个物品的单价即可。 2.如果盒子里面装的不止是一键物品,那么我们就需要比较一下之间的单价了,如果价格相等,那么第一件物品肯定有优势(因为它可以一个一个卖),输出1 -1即可;如果第一件价格小于第二件价格,那么第二件物品就会“一无是处”,直接输出1 -1即可,如果第一件物品价格小于第二件物品价格,且单价要大于第二件物品,那么就可以输出1 b。(恰好为b件,肯定买第二件物品话算,因为

xxxxxiao123的博客 2093

Educational Codeforces Round 80 (Rated for Div. 2) 题解

Educational Codeforces Round 80 (Rated for Div. 2) 【A. Deadline】 【题目大意】 ([]表示想上取整) 【解题思路】 【AC代码】 #include <bits/stdc++.h> #define max(a, b) ((a) > (b) ? (a) :(b)) #define min(a, b) ((a) &lt...

weixin_44211980的博客 892

Educational Codeforces Round 81 (Rated for Div. 2)解题报告

Educational Codeforces Round 81 (Rated for Div. 2) 【A.Display The Number】 【题目大意】 问你用n根火柴能表示的最大数字是多少 【解题思路】 容易想到1只需要两根火柴,那么尽量用1,有多的将第一位改为7 【AC代码】 #include <bits/stdc++.h> #define N 100 #define ma...

weixin_44211980的博客 582

Educational Codeforces Round 112 (Rated for Div. 2)(补题)

B. Two Tables 题意: 给定一个W*H的矩形,在里面有一个蓝色桌子,坐标(左右顶点)(x1,y1)(x2,y2),然后还要在里面放一个红色桌子,要想放开红色桌子,问你蓝色桌子移动的最小距离。 思路: 只需要单一的上下左右移动即可,因为蓝色方块向单一方向移动,对另一个方向是没有贡献的(也可以理解为,因为蓝色方块周边的区域总是有长或者宽是和W或H是一样的,所以就不用再动它了) 知道只用单一移动的话,就把所有情况讨论出来就行了,上下左右移动的最小值取出来就行 #include <bits/st

weixin_54699118的博客 630

Educational Codeforces Round 134 (Rated for Div. 2) A - D

Educational Codeforces Round 134 (Rated for Div. 2)

qq_53504307的博客 242

Educational Codeforces Round 134 (Rated for Div. 2)

思路:最小值好求,只需要在b数组中找到第一个大于a[i]的元素b[j],用b[j]-a[i]即为当前这位的di的最小值.最大值就稍微难一点.我们可知最后一位的对大致是固定的,那么就倒着往前遍历.我们记录当前能和a数组匹配的最大的b数组中元素下标是p.当a[i]>b[i-1]的时候,那么i到p区间内合法最大值都是b[p]-a[i].此时再往前会因为a[i]>b[i-1]而导致规则不成立,直接把p更新为i-1,在继续匹配即可.

qq_49593247的博客 653
上一篇: Codeforces Round #705 (Div. 2)
leslie___
博客等级 码龄7年 21粉丝 50原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值