Codeforces Round #789 (Div. 2) A~E

Activity,ViewPager,Fragment和TabLayout数据传递 描述:Activity顶部嵌着一个按钮供选择类型,TabLayout有三个选项卡,ViewPager有三个Fragment,不论是点击还是滑动到每个Fragment,点击按钮选择类型可改变相对着的Fragment中数据,并且每次滑动或者点击呈现的数据都是按钮类型对应着的。上一下效果图: 问题 activity的数据传递给对应着的Fragment: 1)写一个ViewPager的适配器: 阅读详情

Codeforces Round #789 (Div. 2)

[Link](Dashboard - Codeforces Round #789 (Div. 2) - Codeforces)

A. Tokitsukaze and All Zero Sequence

题意

​ 给你一个数组,每次你可将 a i = a j a_i=a_j ai​=aj​的一个变成 0 0 0或者任选两个使得他们等于 m i n ( a i , a j ) min(a_i,a_j) min(ai​,aj​),问你让数组变成全零的最少操作数

思路

  • 贪心

​ 贪心来想如果有 0 0 0,那就拿 0 0 0每次来做操作,如果有相等的就做操作一再做操作二,否则就做操作二搞出相同的,再做操作一搞出零即可。

Code

#include <bits/stdc++.h>
#define x first
#define y second
#define debug(x) cout<<#x<<":"<<x<<endl;
using namespace std;
typedef long double ld;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef unsigned long long ULL;
const int N = 1e5 + 10, M = 2 * N, INF = 0x3f3f3f3f, mod = 1e9 + 7;
const double eps = 1e-8, pi = acos(-1), inf = 1e20;
int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
int h[N], e[M], ne[M], w[M], idx;
void add(int a, int b, int v = 0) {
    e[idx] = b, w[idx] = v, ne[idx] = h[a], h[a] = idx ++;
}
int n, m, k;
int a[N];
int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int T;
    cin >> T;
    while (T -- ) {
        cin >> n;
        for (int i = 1; i <= n; i ++) cin >> a[i];
        sort(a + 1, a + 1 + n);
        int cnt = 0;
        for (int i = 1; i <= n; i ++)   
            if (!a[i]) {
                cnt ++;
            }
            else {
                break;
            }
        bool ok = false;
        for (int i = 2; i <= n; i ++) 
            if (a[i] == a[i - 1]) {
                ok = true;
                break;
            }
        if (cnt) cout << n - cnt << '\n';
        else if (ok) cout << n << '\n';
        else cout << n + 1 << '\n';
    }
    return 0;
}

B2. Tokitsukaze and Good 01-String (hard version)

题意

​ 给你一个 0 / 1 0/1 0/1串,规定当且仅当所有连续字符相同的最长子串长度均为偶数时称为好串,一次操作可以任意改变一个位置的字符,问你让其改成好串最少需要多少次操作,在此基础上问你最少构成多少个最长子串。

思路

  • 贪心

​ 由于最终要划分成一系列的偶数串,所以每一个奇偶交替的位置如果例如 1 , 2 1,2 1,2对应的字符不同的话,一定要改变一次,可以改成 00 / 11 00/11 00/11。因此最少操作次数就是多少个奇偶位置字符不同。

​ 如何构造最少的子串呢,因为奇偶不同的位置可以随便变成 00 / 11 00/11 00/11,因为我们将字符串按照这些改变的位置切成一段一段,对于每一段如果和前面一段字符一样那么他们就可以拼在一起。

Code

#include <bits/stdc++.h>
#define x first
#define y second
#define debug(x) cout<<#x<<":"<<x<<endl;
using namespace std;
typedef long double ld;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef unsigned long long ULL;
const int N = 1e5 + 10, M = 2 * N, INF = 0x3f3f3f3f, mod = 1e9 + 7;
const double eps = 1e-8, pi = acos(-1), inf = 1e20;
int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
int h[N], e[M], ne[M], w[M], idx;
void add(int a, int b, int v = 0) {
    e[idx] = b, w[idx] = v, ne[idx] = h[a], h[a] = idx ++;
}
int n, m, k;
int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int T;
    cin >> T;
    while (T -- ) {
        cin >> n;
        string str; cin >> str;
        vector<char> ve;
        int res = 0, cnt = 1;
        for (int i = 0; i < n; i += 2) 
            if (str[i] != str[i + 1]) res ++;
            else ve.push_back(str[i]), ve.push_back(str[i + 1]);     
        for (int i = 0; i + 1 < ve.size(); i ++)
            if (ve[i] != ve[i + 1])
                cnt ++;
        cout << res << ' ' << cnt << '\n';
    }
    return 0;
}

C Tokitsukaze and Strange Inequality

题意

​ 给你一排列 p p p,问你有多少组不同的数 [ a , b , c , d ] [a,b,c,d] [a,b,c,d]满足:

  • 1 ≤ a < b < c < d ≤ n 1\le a<b<c<d\le n 1≤a<b<c<d≤n
  • p a < p c , p b > p d p_a <p_c,p_b>p_d pa​<pc​,pb​>pd​

思路

  • 枚举

​ 暴力的话需要 O ( n 4 ) O(n^4) O(n4),肯定不行。考虑优化,想法是对于固定的某个数是否能直接找到某个区间内和他构成的数有多少,例如枚举 a , c a,c a,c,再枚举 b b b,这个时候对于每一个 b b b,我们相当于要找 c c c后面有多少个小于 p b p_b pb​的数,这个可以前缀和预处理搞一下,这样复杂度是 O ( n 3 ) O(n^3) O(n3),还是有点高,考虑我们对于 b b b可以直接找到和他有限制关系的 d d d的数量,因此我们也可以通过 c c c直接找到和他有限制关系的 a a a的数量。

​ 因此枚举 b , c b,c b,c然后对于每一个 b , c b,c b,c查一下 b b b之前有多少个小于 p c p_c pc​的和 c c c之后有多少个小于 p b p_b pb​的,相乘一下即可。

Code

#include <bits/stdc++.h>
#define x first
#define y second
#define debug(x) cout<<#x<<":"<<x<<endl;
using namespace std;
typedef long double ld;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef unsigned long long ULL;
const int N = 1e5 + 10, M = 2 * N, INF = 0x3f3f3f3f, mod = 1e9 + 7;
const double eps = 1e-8, pi = acos(-1), inf = 1e20;
int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
int h[N], e[M], ne[M], w[M], idx;
void add(int a, int b, int v = 0) {
	e[idx] = b, w[idx] = v, ne[idx] = h[a], h[a] = idx ++;
}
int n, m, k;
int a[N];
int mn[5010][5010], mx[5010][5010];
int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int T;
	cin >> T;
	while (T -- ) {
		cin >> n;
		for (int i = 1; i <= n; i ++) cin >> a[i];
		for (int i = 1; i <= n; i ++)
			for (int j = 1; j < i; j ++)
				if (a[j] < a[i])
					mn[i][j] = 1;
				else mn[i][j] = 0;
		for (int i = n; i; i --) 
			for (int j = n; j > i; j --)
				if (a[j] < a[i])
					mx[i][j] = 1;
				else mx[i][j] = 0;
		
		for (int i = 1; i <= n; i ++)
			for (int j = 1; j < i; j ++)
				mn[i][j] += mn[i][j - 1];
		for (int i = 1; i <= n; i ++)
			for (int j = n - 1; j > i; j --)
				mx[i][j] += mx[i][j + 1];

		LL res = 0;
		for (int i = 2; i <= n; i ++)
			for (int j = i + 1; j < n; j ++)
				res += (LL)mn[j][i - 1] * mx[i][j + 1];
		cout << res << '\n';
	}
	return 0;
}

D. Tokitsukaze and Meeting

题意

​ 给你一个长为 n × m 的 0 / 1 n\times m 的0/1 n×m的0/1串和一个 n × m n\times m n×m的矩阵,从前往后执行 n × m n\times m n×m次操作,第 i i i次操作将第 i i i个字符放到矩阵的 ( 1 , 1 ) (1,1) (1,1)然后原来矩阵内的字符按照顺序后延,每次操作后输出有多少个行列包含至少一个 1 1 1。

思路

  • 模拟, d p dp dp思想转移

​ 首先行列是互不影响的所以我们分别考虑行列,假设当前操作了 i i i次

  • 对于行:当前矩形应该是从第一行往下每一行依次是 [ i , i − m + 1 ] , [ i − m , i − 2 × m + 1 ] , . . . [i,i-m+1],[i-m,i-2\times m+1],... [i,i−m+1],[i−m,i−2×m+1],...我们无法复原这个矩阵,这样复杂度过高了,观察这个分布,我们实际上要看的是 [ i , i − m + 1 ] [i,i-m+1] [i,i−m+1]这个区间有没有 1 1 1决定了这一行是否被选,其他的所有行等价成放入第 i − m i-m i−m个字符时候有多少行成立的情况,直接由这个前驱转移过来即可。
  • 对于列:拿个笔画一画发现,对于 i % m i\% m i%m相同的两个数一定在同一列,并且每一次加入一个数,一定是一整列循环的往后移动,因此我们只需要判断当前加入的 i % m i\%m i%m这一列是否有 1 1 1,如果没有 1 1 1并且当前字符为 1 1 1,我们就对这一列打个标记然后列的答案加一下即可。

Code

#include <bits/stdc++.h>
#define x first
#define y second
#define debug(x) cout<<#x<<":"<<x<<endl;
using namespace std;
typedef long double ld;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef unsigned long long ULL;
const int N = 1e5 + 10, M = 2 * N, INF = 0x3f3f3f3f, mod = 1e9 + 7;
const double eps = 1e-8, pi = acos(-1), inf = 1e20;
int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
int h[N], e[M], ne[M], w[M], idx;
void add(int a, int b, int v = 0) {
	e[idx] = b, w[idx] = v, ne[idx] = h[a], h[a] = idx ++;
}
int n, m, k;
int a[N];
int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int T;
	cin >> T; 
	while (T -- ) {
		cin >> n >> m;
		vector<int> s(n * m + 1), col(m), row(n * m + 1);
		int cnt = 0;
		string str; cin >> str;
		for (int i = 0; i < str.size(); i ++)
			s[i + 1] = s[i] + (str[i] == '1');
		for (int i = 1; i <= n * m; i ++) {
			row[i] = row[max(0, i - m)] + (s[i] - s[max(0, i - m)] ? 1 : 0);
			if (!col[i % m] && str[i - 1] == '1') col[i % m] = 1, cnt ++;
			cout << row[i] + cnt << " \n"[i == n * m];
		}
	}
	return 0;
}

E. Tokitsukaze and Two Colorful Tapes

题意

​ 给你两个长度为 n n n的数组 a , b a,b a,b你需要在 a a a里填入 [ 1 , n ] [1,n] [1,n]的排列,且 b b b中和 a a a颜色相同的块具有一样的数字,先让你求 ∑ i = 1 n ∣ a i − b i ∣ \sum_{i=1}^n \mid a_i-b_i\mid ∑i=1n​∣ai​−bi​∣的最大值。

思路

  • 贪心,找环

​ 首先我们 a i → b i a_i\to b_i ai​→bi​这个颜色连接一条边,则会形成若干个环,我们将边权定义为相邻两结点的权值差的绝对值,则所有边权和就等价于我们要求的东西,对于奇偶环我们分开来看。

  • 偶数:对于环上的一个三个相邻的点 a , b , c a,b,c a,b,c来说,对应的边权为 ∣ b − a ∣ \mid b-a \mid ∣b−a∣, ∣ c − b ∣ \mid c - b \mid ∣c−b∣,假设 b b b的点权是其中最大的则为 b − a , b − c b-a,b-c b−a,b−c,假设偶数环有四个点 a < b < c < d a<b<c<d a<b<c<d,则边权为 2 × ( c + d ) − 2 × ( a + b ) 2\times (c+d)-2\times(a+b) 2×(c+d)−2×(a+b),为了让权值更大因此我们尽量让 c , d c,d c,d更大, a , b a,b a,b更小。
  • 奇数:奇数同偶数不同的就是,会有一个点没有贡献,例如 1 , 2 , 3 1,2,3 1,2,3三个点,边权有 2 − 1 , 3 − 2 , 3 − 1 2-1,3-2,3-1 2−1,3−2,3−1,则点 2 2 2会消除掉,因此奇数环我们只能填 n − 1 n-1 n−1个有用的数,有一个会自己抵消,

那么就是我们有一些环,每个环有一半的点是正的 × 2 \times 2 ×2,有一半的点是负的 × 2 \times 2 ×2,贪心来看我们一定是,大的数赋予正权值,小的赋予负权值,中间的赋予零就是自己将自己抵消了,因此算一下有多少个没被抵消的点,即可。

Code

#include <bits/stdc++.h>
#define x first
#define y second
#define debug(x) cout<<#x<<":"<<x<<endl;
using namespace std;
typedef long double ld;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef unsigned long long ULL;
const int N = 1e5 + 10, M = 2 * N, INF = 0x3f3f3f3f, mod = 1e9 + 7;
const double eps = 1e-8, pi = acos(-1), inf = 1e20;
int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
int h[N], e[M], ne[M], w[M], idx;
void add(int a, int b, int v = 0) {
	e[idx] = b, w[idx] = v, ne[idx] = h[a], h[a] = idx ++;
}
int n, m, k;
int a[N], b[N];
int f[N], cnt[N];
int find(int x) {
	return x == f[x] ? x : f[x] = find(f[x]);
}
int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int T;
	cin >> T;
	while (T -- ) {
		cin >> n;
		for (int i = 1; i <= n; i ++)
			cin >> a[i], cnt[i] = 1, f[i] = i;
		for (int i = 1; i <= n; i ++) {
			int x; cin >> x;
			int xx = find(x), yy = find(a[i]);
			if (xx != yy) {
				f[xx] = yy;
				cnt[yy] += cnt[xx];
			}
		}

		int v = 0;
		for (int i = 1; i <= n; i ++) 
			if (i == f[i]) 
				v += cnt[i] / 2;
		cout << 2ll * (n + n - v + 1) * v / 2 - 2ll * (1 + v) * v / 2 << '\n';


	}
	return 0;
}
【算法基础课】整数二分查找:数的范围 文章目录1.思想2.例题3.代码模板 1.思想 本质是:边界!有一半区间满足条件,一半不满足。我们可以找到这两个区间的边界。 2.例题 给定一个按照升序排列的长度为n的整数数组,以及 q 个查询。对于每个查询,返回一个元素k的起始位置和终止位置(位置从0开始计数)。如果数组中不存在该元素,则返回“-1 -1”。 输入格式 第一行包含整数n和q,表示数组长度和询问个数。第二行包含n个整数(均在1~10000范围内),表示完整数组。接下来q行,每行包含一个整数k,表示一个询问元素。 输出格式 共q行,每行包含 阅读详情

相关推荐

LCD驱动芯片——BL55072A驱动程序

初始化子程序: START 0x7C; I2C子地址 0xEA;ICSET,软件复位芯片 0xC0;MODSET,关显示 0xF0;BLKCTL,关闪烁 0xA3;DISCTL,80Hz Line inversion,High Power mode 0xE8;ICSET,清复位bit1 STOP 显示刷新子程序: START 0x7C;I2C子地址 0xF0;BLKCTL,关闪烁 0xA3;DISCTL,80Hz Line inversion,High Power mode 0xE8或0xEC;ICSE

love421的博客 3175

拨号上网遇到“错误789”提示

拨号上网遇到“错误789”提示   问题:以前上网正常过了年之后再拨号上网出现:“错误789”的提示。   解决:重启猫,重启之后不要马上登录拨号器,要等一会,大概等到1分钟之后再用拨号器进行拨号就可以了。   问题:通过交换机和路由器,想让两台电脑都上网,发现只有一台电脑可以上网。拓扑:  解决:最后发现在插拔中把交换机上的线头插错了。把接往路由器上的线接到交换机上的蓝空中。

fushengruoke的专栏 1万+

手把手教你用S7-PLCSIM Advanced V3.0搭建PLC仿真测试环境(含WinPcap避坑指南)

本文详细介绍了如何使用西门子S7-PLCSIM Advanced V3.0搭建PLC仿真测试环境,包括WinPcap 4.1.3驱动的安装避坑指南。从环境准备、软件安装到配置调试,提供了一套完整的解决方案,帮助工程师和教学人员快速构建可靠的PLC仿真环境,解决常见的报错问题。

weixin_30879169的博客 641

L2TP连接错误 789 解决方法

错误提示 789 错误 , 提示 L2TP 协议与远程连接出错。 L2TP 连接尝试失败,因为安全层在与远程计算机进行初始协商时遇到处理错误 解决方法 单击“开始”,单击“运行”,键入regedit,打开注册表编辑器 找到下面的注册表子项,然后单击它: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Rasman\Parameters 在“编辑”菜单上,单击“新建”->“DWORD值(32位)” 在“名称”框中,键入“ProhibitI

采蘑菇的Mario 1万+

从个体到群体:Cartool实战静息态EEG微状态聚类全解析

本文详细解析了使用Cartool软件进行静息态EEG微状态聚类的完整实战流程。从个体水平聚类到群体模板提取,再到指标量化,文章深入探讨了k-means算法的应用、GFP峰值数据的使用技巧以及关键参数设置,为脑电信号处理研究者提供了从数据准备到结果解读的全方位指南。

weixin_29062671的博客 290

树莓派通过TTL3.3转485 Modbus采集水表

所需道具 树莓派0,我用的是树莓派zero wh; 具有光电直读功能的有线水表,我用的是咸鱼淘的埃美柯LXSY-20E1; TTL3.3 转 485模块,带隔离的贵些; 5V转12V升压模块。 原理 树莓派有UART(GPIO14 Tx 和 GPIO15 Rx)串口通讯功能,电器特性是3.3V TTL,直读远传水表支持M-Bus/485通讯接口,我买的光电直读水表485要求12V供电(根据仪表厂家说明书)。TTL和485虽然都是串口通讯,但电器特性不一样,不能直接接!我已经烧掉一个树莓派...

xhydongda的博客 3443

AcWing 789: 数的范围

给定一个按照升序排列的长度为n的整数数组,以及 q 个查询。 对于每个查询,返回一个元素k的起始位置和终止位置(位置从0开始计数)。 如果数组中不存在该元素,则返回“-1 -1”。 输入格式 第一行包含整数n和q,表示数组长度和询问个数。 第二行包含n个整数(均在1~10000范围内),表示完整数组。 接下来q行,每行包含一个整数k,表示一个询问元素。 输出格式 共q行,每行包含两个整数,表示所求元素的起始位置和终止位置。 如果数组中不存在该元素,则返回“-1 -1”。 数据范围 1≤

StrawberryMuMu的博客 168

Kindle电子书DRM破解全攻略:从下载到转换的完整流程(含最新DeDRM插件配置)

本文详细介绍了2025年最新Kindle电子书DRM移除的完整实战流程。针对亚马逊加密机制的升级,文章重点讲解了如何配置最新的DeDRM插件、从新版Kindle客户端提取密钥,并利用Calibre完成电子书的解密与格式转换,为个人备份提供了一套可行的解决方案。

weixin_29279153的博客 1738

div2 1064补题笔记(A~E)

思路:看看字符串和最后一个字符不同的字符数有多少个即为答案,代码略。

2301_81675368的博客 913

107.在 Vue 3 中使用 OpenLayers 实现视图联动功能

是一个非常强大的 Web 地图渲染库,支持多种地图数据格式和交互操作。在 Vue 3 中,我们可以利用。绑定到真实的 DOM 元素上,我们就可以用它们来初始化 OpenLayers 地图。来封装和管理 OpenLayers 地图的状态,从而更高效地开发地图应用。,即两个地图窗口共享同一个视图(View),从而实现同步缩放、拖动等操作。这可以确保 Vue 组件销毁时,OpenLayers 也正确销毁地图实例。,并且它们会同步缩放和拖动,达到地图联动的效果。这样,无论你拖动哪个地图,另一个都会同步变化。

小彭的博客 1938

激光雷达的64线,32线,16线,你弄懂了吗?

激光雷达的 64 线、32 线、16 线是指激光雷达系统中能够同时发射和接收激光脉冲的激光线的数量5。

谢谢大家的关注和点赞!这里只有纯纯的知识干货,没有一句废话。希望能实实在在帮到大家~要是觉得有用,别忘了给我点支持哟,你 2637

Codeforces Round #789 (Div. 2)

CF系列题解 Codeforces Round #789 (Div. 2)题目A. Tokitsukaze and All Zero Sequence原题链接题意题解思路代码B1. Tokitsukaze and Good 01-String (easy version)原题链接题意题解思路代码B2. Tokitsukaze and Good 01-String (hard version)原题链接题意题解思路代码C. Tokitsukaze and Strange Inequality原题链接题意题解.

weixin_56898701的博客 1014

【教程4>第8章>第10节】OFDM完整通信链路项目的FPGA开发4——插入导频

本文介绍了基于MATLAB和Verilog的导频插入设计与实现方法。首先回顾了MATLAB中导频插入的算法实现,展示了每32个数据插入一个导频的设计。接着详细说明了Verilog硬件实现方案,包括导频序列定义、计数器设计、FIFO模块等关键部分。通过仿真测试验证了设计的正确性,输出了插入导频后的序列、导频序列以及调整时序后的序列。最后提供了相关视频教程资源,帮助读者理解设计过程。该设计实现了数据与导频的精确插入,为OFDM等通信系统开发提供了实用参考。

FPGA/MATLAB学习教程/源码/项目合作开发 395

Codeforces Round #789 (Div. 2) B~E

Codeforces Round #789 (Div. 2) B~F B.Tokitsukaze and Good 01-String 链接 题意:给出01字符串,要求每次可以修改一个地方,最后要让连续的1和连续的0的长度都是偶数,输出最下操作次数和最后的段数 思路:首先考虑都变成奇数,从头开始每次跳2,假如不一样,说明出现了奇数的0或者1,就需要变成,然后统计段数,当和最后一次记录不同的时候,说明段数加一 #include<bits/stdc++.h> using namespace std;

qq_51672768的博客 334

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

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

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

Codeforces Round #789 (Div. 2) [已补BCDE,F待补]

Codeforces Round #789 (Div. 2) [已补BCDE,F待补] Problem - B1 - Codeforces tags 贪心 思路 最少操作数:对于11,00这类我们不需要取操作它们,而对于10,01,我们需要把它们改成11或00 所以我们就把a pair看作一组,出现01、10的次数即为我们的操作数 而对于最小字段数量:我们去进行上面操作的时候,把10、01改11、00的时候,取决于前面哪个一对是11还是00,改成与前面相同的,这样修改的pair就不会对子段数量有贡献。

meet snow happy 336

深度学习工具包 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 #789 (Div. 2)题解

Codeforces Round #789 (Div. 2)题解

T_Y_F_的博客 1008

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

Codeforces Round #789 div2

Round #789 (Div. 2) 文章目录A. Tokitsukaze and All Zero Sequence(签到)B2. Tokitsukaze and Good 01-String (hard version)(贪心)C. Tokitsukaze and Strange Inequality(枚举+前缀和) A. Tokitsukaze and All Zero Sequence(签到) 思路:分类讨论:若序列中有000,ans=n−tt(0)ans=n-tt(0)ans=n−tt(0);若

qq_53287227的博客 583

Codeforces Round #789 (Div. 2)(A-D)

Codeforces Round #789 (Div. 2) A. Tokitsukaze and All Zero Sequence 一个小小的思维贪心,很容易知道如果有0,直接用0去和其他数处理,如果没有就先创造一个 #include <bits/stdc++.h> using namespace std; #define int long long const int M = 1e9 + 7; const int N = 2e6 + 9; int a[N]; signed main() {

weixin_51771856的博客 274

Codeforces Round #789 (Div. 2) A~F个人题解

A. Tokitsukaze and All Zero Sequence 题意:有一个长度为n的数组a,每次可以从数组种选择俩个下标不同的元素进行下面俩个操作: (1)如果两个元素相同,把其中一个变成0,() (2)如果两个元素不同,把两个元素都变成这两个的最小值() 问,最少的操作数把数组a全部变成0? 知识点:思维 思路:可以分类一下, 1、如果数组中本来就有0,那操作数一定是不为0的数和0进行(2)操作,答案就是不为0的个数 2、如果数组中没有0,但是有相同的两个元素,那进行一次(1)

qq_53446104的博客 1584

Codeforces Round #789 (Div. 2) F. Tokitsukaze and Permutations

Codeforces Round #789 (Div. 2) Tokitsukaze and Permutations 链接 题意:给出序列c,代表第i位之前有cic_ici​个比他大的数字,如果是-1就是不知道,现在进行k次操作,每次操作如果ai>ai+1a_i > a_{i+1}ai​>ai+1​,就交换这两个数字,直到最后一个,类似冒泡排序,求有多少个排列进行k次操作之后,他的viv_ivi​和给你的viv_ivi​是相同的。 思路:明天来写自己理解的 #include<bit

qq_51672768的博客 409

Codeforces Round #690 (Div. 3)

文章目录Codeforces Round #690 (Div. 3)A.Close TuplesB.Close TuplesC.Close TuplesD.Close TuplesE.Close TuplesF.The Treasure of The Segments Codeforces Round #690 (Div. 3) 比赛的时候f想到思路,写了一半比赛就结束了,难受 A.Close Tuples 题意: 题解: 代码: /* 6 7 3 4 5 2 9 1 1 4 9 2 7 1 11 8 4

m0_49959202的博客 217

Codeforces Round #811 (Div. 3)

1

nttttt の blog 313

Codeforces Round #789 (Div. 2 题解ABCD

A 题直接照着题意模拟没什么好说的 #include<iostream> #include<stdio.h> #include<string.h> #include<queue> #include<map> #include<algorithm> #include<stack> #include<set> #include<string> #include<utility> #in...

qq_62165099的博客 281

Codeforces Round #789 (Div. 2) A B1 B2 C D E

Codeforces Round #789 (Div. 2) A B1 B2 C D E A.Tokitsukaze and All Zero Sequence 题意: 给你一个长度为nnn的aaa数组,你每次操作可以进行下述两种操作的任意一种,求最小操作数使aaa数组所有数变成000: 如果222个数相同,可以使其中一个数变成000。 设两个数为aaa和bbb,可以使其中一个数变成min(a,b)min(a,b)min(a,b)。 思路: 分类讨论,如果存在000,那么最小操作数即非000的个数。 如

qq_53504307的博客 383
上一篇: Sorting Pancakes(dp)
下一篇: D. Dog Walking(枚举,贪心)
枉玊
博客等级 码龄6年 73粉丝 171原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值