Codeforces Round #340 (Div. 2) (617A,617B,617C,617D(Constructive ),617E(莫队算法))

基于Python的Codeforces竞赛数据抓取与分析实战 数据抓取与分析是理解在线平台生态的核心技术。其原理在于通过自动化脚本模拟浏览器行为,从目标网站获取公开数据,并利用数据处理库进行清洗、统计与可视化。这项技术的价值在于能将海量、非结构化的信息转化为可量化的洞察,极大地提升研究、复盘与决策的效率。在算法竞赛领域,它常被应用于分析题目难度趋势、高频考点分布以及选手行为模式。本文以Codeforces平台为例,详细讲解了如何构建一个完整的分析工具链,涵盖从合规抓取、指标计算到报告生成的全过程,并重点探讨了如何通过Python的requests、pandas等库实现 阅读详情

比赛的时候由于入了一道题的坑,而且一直没爬出来。。。

Elephant

题目连接:

http://codeforces.com/contest/617/problem/A

解题思路:

It's optimal to do the biggest possible step everytime. So elephant should do several steps by distance 5 and one or zero step by smaller distance. Answer equals to 

AC代码:

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int main(){
    int x;
    scanf("%d",&x);
    if(x%5)
        printf("%d\n",x/5+1);
    else
        printf("%d\n",x/5);
    return 0;
}

Chocolate

题目连接:

http://codeforces.com/contest/617/problem/B

解题思路:

We are given array which contains only ones and zeroes. We must divide it on parts with only one 1.

Tricky case: when array contains only zeroes answer equals to 0.

In general. Between two adjacent ones we must have only one separation. So, answer equals to product of values posi - posi - 1 whereposi is position of i-th one.

弱英语差,没看到这句话:You are asked to calculate the number of ways he can do it. 

AC代码:

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

typedef long long ll;
int a[110];

int main(){
    int n;
    while(~scanf("%d",&n)){
        for(int i = 0; i < n; i++)
            scanf("%d",&a[i]);
        int i;
        for(i = 0; i < n; i++){
            if(a[i] == 1)
                break;
        }
        if(i == n){
            printf("0\n");
            continue;
        }
        ll cnt = 1,ans = 1;
        for(; i < n; i++){
            if(a[i] == 1){
                ans *= cnt;
                cnt = 1;
            }
            else
                cnt++;
        }
        printf("%lld\n",ans);
    }
    return 0;
}


Watering Flowers

题目连接:

http://codeforces.com/contest/617/problem/C

解题思路:

First radius equals to zero or distance from first fountain to some flower. Let's iterate over this numbers. Second radius equals to maximal distance from second fountain to flower which doesn't belong to circle with first radius. Now we should choose variant with minimalr12 + r22.

AC代码(n^2):

#include <iostream>
#include <vector>
#define INF 1e18
using namespace std;

typedef long long ll;

ll square(int x){
    return (ll)x * x;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);

    int n, x1, y1, x2, y2;
    while(cin >> n >> x1 >> y1 >> x2 >> y2){
        vector<pair<ll, ll> > dist(n);
        for (int i = 0; i < n; i++) {
            int x, y;
            cin >> x >> y;
            dist[i].first = square(x - x1) + square(y - y1);
            dist[i].second = square(x - x2) + square(y - y2);
        }
        dist.push_back({0, 0});

        ll result = INF;
        for(int i = 0; i <= n; i++){
            ll r1 = dist[i].first;
            ll r2 = 0;
            for(int j = 0; j <= n; j++){
                if(dist[j].first > r1){
                    r2 = max(r2, dist[j].second);
                }
            }
            result = min(result, r1 + r2);
        }
        cout << result << endl;
    }
    return 0;
}

AC代码(nlogn):

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;

ll square(int x) {
    return x * (ll) x;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);

    int n, x1, y1, x2, y2;
    while(cin >> n >> x1 >> y1 >> x2 >> y2){
        vector< pair<ll, ll> > dist(n);
        for (int i = 0; i < n; i++) {
            int x, y;
            cin >> x >> y;
            dist[i].first = square(x - x1) + square(y - y1);
            dist[i].second = square(x - x2) + square(y - y2);
        }

        sort(dist.begin(), dist.end());
        vector<ll> maxsuf(n + 1);
        for (int i = n - 1; i >= 0; i--) {
            maxsuf[i] = max(maxsuf[i + 1], dist[i].second);
        }

        ll result = min(dist[n - 1].first, maxsuf[0]);
        for (int i = 0; i < n; i++) {
            ll r1 = dist[i].first;
            ll r2 = maxsuf[i + 1];
            result = min(result, r1 + r2);
        }
        cout << result << endl;
    }
    return 0;
}

Polyline

题目连接:

http://codeforces.com/contest/617/problem/D

解题思路:

Answer equals to one if all coordinates x or y of points are same.

When answer equals to two? Let's iterate over all pairs of points. Let first point in pair is beginning of polyline, second point is end. Only one or two such polylines with answer two exist. If third point is on the polyline it belongs to rectangle with corners in first two points. We can just check it.

Else answer equals to three. We can build vertical lines which contains the most left and the most right point and horizontal line through third point. If we erase some excess rays we will get polyline.

AC代码:

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int x[3], y[3];

bool is_between(int a, int b, int c) {
    return min(a, b) <= c && c <= max(a, b);
}

bool judge(int i, int j, int k) {
    return (x[k] == x[i] || x[k] == x[j]) && is_between(y[i], y[j], y[k]) ||
           (y[k] == y[i] || y[k] == y[j]) && is_between(x[i], x[j], x[k]);
}

int main(){
    for(int i = 0; i < 3; i++)
        scanf("%d%d",&x[i],&y[i]);

    if(x[0] == x[1] && x[1] == x[2] || y[0] == y[1] && y[1] == y[2]){
        puts("1");
    }else if(judge(0,1,2) || judge(0,2,1) || judge(1,2,0)){
        puts("2");
    }else{
        puts("3");
    }
    return 0;
}


XOR and Favorite Number

题目连接:

http://codeforces.com/contest/617/problem/E

解题思路:

We have array a.

Let's calculate array pref (pref[0] = 0, ).

Xor of subarray a[l...r] equals to .

So query (l, r) is counting number of pairs i, j (l - 1 ≤ i < j ≤ r) .

Let we know answer for query (l, r) and know for all v cnt[v] — count of v in a[l - 1...r]. We can update in O(1) answer and cnt if we move left or right border of query on 1. So we can solve problem offline in  with sqrt-decomposion (Mo's algorithm).

AC代码:

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long ll;
const int blocks = 300;

struct Query{
	int l, r, id;
	bool operator < (const Query& other) const{
		return l / blocks < other.l / blocks || (l / blocks == other.l / blocks && r < other.r);
	}
};

int n, m, k;
Query q[100000];
ll ans[100000];
int s[100001];
int cnt[1 << 20];
ll cur;

void add(int x){
	cur += cnt[x ^ k];
	cnt[x]++;
}

void del(int x){
	cnt[x]--;
	cur -= cnt[x ^ k];
}

int main(){
    while(~scanf("%d%d%d",&n,&m,&k)){
        for (int i = 1; i <= n; i++){
            scanf("%d", &s[i]);
            s[i] ^= s[i - 1];
        }
        for (int i = 0; i < m; ++i){
            scanf("%d%d",&q[i].l,&q[i].r);
            q[i].id = i;
        }
        sort(q,q+m);
        int l = 1, r = 0;
        for(int i = 0; i < m; ++i){
            while(q[i].l - 1 > l)
                del(s[l++]);
            while(q[i].l - 1 < l)
                add(s[--l]);
            while(q[i].r > r)
                add(s[++r]);
            while(q[i].r < r)
                del(s[r--]);
            ans[q[i].id] = cur;
        }
        for (int i = 0; i < m; ++i){
            printf("%lld\n", ans[i]);
        }
    }
	return 0;
}


Subdivision Methods for Geometric Design - A Constructive Approach 计算机图形学中关于 细分表面、几何处理的一本好书 立即下载

相关推荐

基于ROS2 Humble与Livox Mid-360的双雷达点云融合实战解析

本文详细解析了基于ROS2 Humble与Livox Mid-360的双雷达点云融合实战方案。从环境搭建、驱动安装、双雷达配置、外参标定、时间同步到点云融合核心实现,全面介绍了技术要点与避坑指南,并提供了工程化部署与性能优化建议,助力开发者高效实现高精度点云合成应用。

ss78901的博客 1093

Codeforces 2026上半年赛事深度复盘:从比赛筛选到高效训练指南

在算法竞赛领域,系统性复盘是提升实力的核心。其原理在于通过分析大量比赛数据,识别高质量题目与有效训练路径,从而将有限时间价值最大化。对于Codeforces这类高频赛事平台,选手常面临“打哪些比赛、复盘哪些题”的困惑。本文基于2026年上半年超过60场常规Round的实战数据,从题目质量、难度曲线、出题人风格等维度进行横向对比,旨在解决信息筛选与价值判断问题。通过建立难度坐标系和规划个人训练路径,帮助不同Rating区间的选手识别“信号”与“噪音”,高效利用比赛资源,洞察出题趋势,实现针对性突破。

weixin_33857230的博客 435

3D坐标系转换实战:如何用Python快速实现旋转矩阵与平移向量的组合变换

本文详细介绍了如何使用Python和NumPy实现3D坐标系转换中的旋转矩阵与平移向量的组合变换。通过齐次坐标和变换矩阵的数学原理,结合代码示例,帮助开发者高效处理机器人路径规划和计算机视觉中的空间变换问题,并解决实际应用中的常见错误。

pluto的博客 959

CodeForces 617E XOR and Favorite Number(莫队)

题意: 给你n个数,m次询问,询问给你(l,r),问你满足l ≤ i ≤ j ≤ r, ai^(ai+1)^...aj = k的区间数。 思路:因为又是区间又是没修改的询问,很容易想到莫队,但是怎么O(1)转移呢,可以利用异或的前缀和,具体思路可 以看官方题解: We have array a. Let's calculate array pref (pref[0] =

CillyB的博客 446

Cesium.Ray 知识详解,示例代码

Cesium.Ray 是 CesiumJS 中用于表示三维空间中无限射线的核心类,广泛应用于地理信息系统(GIS)、三维可视化和碰撞检测等场景。射线由起点(origin)和方向向量(direction)定义,数学表达式为 ( P(t) = \text{origin} + t \times \text{direction} )。核心属性包括起点和方向向量,常用方法包括射线与平面的交点计算、根据距离获取射线上的点等。在 Cesium 中,Cesium.Ray 常用于地形碰撞检测、鼠标点选对象和雷达探测模拟等场景

大剑师兰特的GIS世界 425

火焰烟雾识别系统【数据集+源码+UI界面】

数据集准备:收集并标注火焰与烟雾数据。YOLOv10训练:训练YOLOv10模型来识别火焰和烟雾。实时检测:通过摄像头视频流进行实时检测,并显示检测结果。UI界面设计:用Tkinter设计简易界面,显示检测结果。完成以上步骤后,可以实现一个完整的火焰烟雾识别系统,具备实时检测与友好的用户界面。

2201_76125393的博客 1135

Codeforces Round 915 (Div. 2) A-F(补题&补写法)

即一棵大小为n的根id=1的树,变为大小为n的根id=2的树(或变为根id=3的树)时,称一个位置x是good的,当且仅当所有ypx,其实就是,将(x,px)看成是二维平面点的时候,左侧的点都在左下方,右侧的点都在右上方。所以,可能产生贡献的位置对,只有2*n个,暴力检查这2*n个,能快速算贡献改变量即可。因为,将(i,pi)看成是二维平面点的时候,左侧的点都在左下方,右侧的点都在右上方,即x/2上取整,x/2下取整,(x-1)/2上取整,(x-1)/2下取整,

小衣同学的博客 3074

YOLO26改进 - C2PSA | C2PSA融合CPIASA跨范式交互与对齐自注意力机制 : 交互对齐机制,提升小目标与遮挡目标判别力 | ACM MM2025

本文介绍了跨范式表征与对齐Transformer(CPRAformer)及其核心的跨范式交互与对齐自注意力机制(CPIA - SA),并阐述了其在YOLO26中的结合应用。传统图像去雨模型特征提取局限大,CPIA - SA通过协同“空间 - 通道”与“全局 - 局部”范式解决该问题,由SPC - SA、SPR - SA和AAFM子模块构成,经双路提取、动态过滤、空间细化、对齐融合四步工作。我们将相关代码引入指定目录,在`ultralytics/nn/tasks.py`中注册,配置`yolo26 - C2PS

魔改工程师的博客 665

Codeforces 1088 Div1+2(ABC1C2DEF)

CF1088Div1+2

2402_89326161的博客 437

安装openclaw时出现npm error code ENOENT npm error syscall spawn git报错的解决方案

本文主要介绍了安装openclaw时出现npm error code ENOENT npm error syscall spawn git报错的解决方案,希望能对使用openclaw的同学们有所帮助。 文章目录 1. 问题描述 2. 解决方案

weixin_43178406的博客 12万+

rk3568 Android12 默认授予预装app权限

默认授予预装应用权限可以避免用户在每次使用应用时都要重复同意权限请求。尽管在Android 12中,用户对权限的管理有了更高的控制权,但这也可能导致用户在频繁使用预装应用时感到繁琐和不必要的干扰。通过默认授权,减少了这种麻烦。一些厂商可能会根据其定制的Android系统(如Samsung的One UI、Xiaomi的MIUI)要求某些预装应用默认获得权限,以便应用能够提供厂商特定的功能。这也有助于设备厂商提供统一和稳定的服务,不至于因为权限问题导致某些功能无法使用。

weixin_35723192的博客 661

Codeforces Round 915(Div.2) A~F

给出一个n×m的网格,你需要将网格上所有点均填满水,当一个格子同时满足以下两个条件时,格子中也会被填满水:该格子的左边或右边已经被填满水了该格子的上面或下面已经被填满水了一次操作可以给一个格子填满水,问至少几次操作才能将所有网格填满。

Code_Shark的博客 1332

【深度学习】最强算法之:残差网络(ResNet)

一篇掌握深度学习算法之:残差网络

商务合作 | 面试培训 | 职场规划 ==>主页扫码 7837

Codeforces Round #719 (Div. 3) 1520

math #include <bits/stdc++.h> using namespace std; #define FI first #define SE second #define MP make_pair #define PB push_back #define rep(i, a, b) for(int i=(a); i<(b); i++) #define per(i, a, b) for(int i=(b)-1; i>=(a); i--) typedef long long

m0_53091571的博客 95

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

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

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

Codeforces Round #346 (Div. 2) (659A,659B,659C,659D(几何叉乘),659E(并查集))

Round House 题目链接: http://codeforces.com/problemset/problem/659/A 解题思路: The answer for the problem is calculated with a formula ((a - 1 + b)  n + n)  n + 1. Such solution has complexity

piaocoder 1857

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

April Fools Day Contest 2016 (656A,656B,656C,656D,656E,656F)

Da Vinci Powers 题目链接: http://codeforces.com/problemset/problem/656/A 解题思路: This problem asked to figure out an integer sequence from two samples and problem title. It turned out to be surprising

piaocoder 1437

深度学习工具包 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&#39;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(&#39;DeepLearnToolbox&#39;));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(&#39;state&#39;,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&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,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 = &#39;sigm&#39;;%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, &#39;Too big error&#39;);```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(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;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)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;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, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% 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&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 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, &#39;Too big error&#39;);```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(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % 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, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % 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, &#39;Too big error&#39;);%% 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(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % 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, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Codeforces Round #323 (Div. 2) (583A,583B,582A,582B)

1.Asphalting Roads 题目链接: http://codeforces.com/problemset/problem/583/A 解题思路: To solve the problem one could just store two arrays hused[j] and vused[j] sized n and filled with false initial

piaocoder 1192

Codeforces Round #340 (Div. 2) (629A,629B,629C(排列组合,动态规划),629D(线段树))

Far Relative’s Birthday Cake 题目链接: http://www.codeforces.com/problemset/problem/629/A 解题思路: Consider that we have rowi chocolates in the i'th row and coli chocolates in the i'th column.

piaocoder 1177

Codeforces Round #326 (Div. 2) (588A,588B,587A)

1.Duff and Meat 题目链接: http://codeforces.com/problemset/problem/588/A 解题思路: Idea is a simple greedy, buy needed meat for i - th day when it's cheapest among days 1, 2, ..., n. So, th

piaocoder 1061

Codeforces Round #329 (Div. 2) (593A,593B,593C,593D)

2Char 题目链接: http://codeforces.com/problemset/problem/593/A 解题思路: For each letter will maintain the total length of words (cnt1ci), which found it was alone, and for each pair of letters wi

piaocoder 990

Codeforces Round #324 (Div. 2) (584A,584B(排列组合),584C(构造),584D(哥德巴赫猜想),584E(置换群))

1.Olesya and Rodion 题目链接: http://codeforces.com/problemset/problem/584/A 解题思路: Two cases: t = 10 and t ≠ 10. If t = 10 then there are two cases again :). If n = 1 then answer is

piaocoder 971

Codeforces Round #325 (Div. 2) (586A,586B,585A,585B)

1.Alena's Schedule 题目链接: http://codeforces.com/problemset/problem/586/A 解题思路: To solve this problem one should remove all leading and trailing zeroes from array and then calculate the nu

piaocoder 963

8VC Venture Cup 2016 - Elimination Round (626A,626B,626C(二分),626D(概率))

Robot Sequence 题目连接: http://codeforces.com/problemset/problem/626/A 解题思路: We can simulate Calvin’s path on each substring, and check if he returns to the origin. Runtime: O(n3) AC代码: #i

piaocoder 942

Codeforces Round #317 (Div. 2) (572A Arrays,572B Order Book)

1.572A Arrays 题目链接: http://codeforces.com/problemset/problem/572/A 解题思路: 取第一个数列的第k个数,然后倒着取第二个数列的第m个数,比较即可。。。 AC代码: #include #include #include using namespace std; int a[100005]; int b[10

piaocoder 872

Codeforces Round #365 (Div. 2) (703A,703B(容斥),703C(几何),703D(树状数组))

Mishka and Game 题目链接: http://codeforces.com/problemset/problem/703/A 解题思路: In this problem you had to do use the following algo. If Mishka wins Chris in the current round, then increase variable

piaocoder 800
上一篇: BestCoder Round #69 (div.2)(hdu5610,hdu5611,hdu5612(动态规划))
下一篇: Codeforces Round #340 (Div. 2) (618A,618B,618C)
yphacker
博客等级 码龄12年 199粉丝 540原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值