算法训练 DAY-1

题解:AcWing 1014 登山 题目涵盖了从基础到进阶的多种算法和数据结构,旨在为不同阶段的编程学习者提供一条清晰、平稳的学习提升路径。同时队员们还有另一个登山习惯,就是不连续浏览海拔相同的两个景点,并且一旦开始下山,就不再向上走了。个景点,并且决定按照顺序来浏览这些景点,即每次所浏览景点的编号都要大于前一个浏览景点的编号。队员们希望在满足上面条件的同时,尽可能多的浏览景点,你能帮他们找出最多可能浏览的景点数么?五一到了,ACM队组织大家去登山观光,队员们发现山上一共有。输出一个整数,表示最多能浏览的景点数。个整数,表示每个景点的海拔。 阅读详情

一、洛谷P5440 【XR-2】奇迹

题目描述

我们称一个日期为一个八位数,第 1~4 位构成年,第 5~6 位构成月,第 7~8 位构成日,不足位数用 0 补足。同时,要求日期所代表的这一天真实存在,且年的范围为 1~9999。

出现奇迹的日期都存在相同的特点:由“日”组成的两位数,由“月+日”组成的四位数,由“年+月+日”组成的八位数均为质数。但并不是所有存在这样特点的日期都一定会出现奇迹。

现在,你得到了一个可能会出现奇迹的日期,然而不幸的是这个日期却是残缺的,八位中可能有若干位无法确定。你需要知道这个日期有多少种可能,这样你才能做好充足的准备去迎接奇迹的到来。

输入格式

本题有多组数据。

第一行一个正整数 T T T,表示数据组数。

接下来的 T T T 行,每行一个八位字符串。其中第 i i i 位如果为 -,则表示日期的第 i i i 位无法确定,否则表示日期的第 i i i 位为字符串中第 i i i 位上的数字。

输出格式

对每组数据,一行一个整数,表示答案。

样例1

2
53-7-3-7
20190629

样例输出1

6
0

提示

【样例 1 1 1 说明】

53-7-3-7 的 6 6 6 种可能的日期如下:

53070307
53070317
53170307
53370307
53570317
53770307

【数据规模与约定】

一共 10 10 10 个测试点,记 c c c 为八位字符串中 - 的个数。

对前 9 9 9 个测试点,在第 i i i 个测试点中保证 c = i − 1 c = i - 1 c=i−1。

对 100 % 100\% 100% 的数据保证 1 ≤ T ≤ 10 1 \le T \le 10 1≤T≤10。

代码实现

#include<bits/stdc++.h>
using namespace std;
#define ios ios::sync_with_stdio(0); cin.tie(0),cout.tie(0);
const int N = 100010;
int cnt;
string s;
int ans;
int pri[N];
bool st[N];
int de[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
bool ff(int n)
{
    if(n<2)
    {
        return false;
    }
    for(int i = 2;i <= n/i;i++)
    {
        if(n%i==0)
        {
            return false;
        }
    }
    return true;
}
bool checkdate(int n)
{
    int day = n % 100;
    int mon = n % 10000 / 100;
    int year = n /10000;
    if(year < 1 || year > 9999 ) return false;
    if(mon < 1 ||  mon >12) return false;
    if(mon == 2)
    {
        if(day == 29 && ((year % 4 == 0) && (year % 100 != 0) ||  year % 400 == 0))
        {
            return true;
        }
    }
 
    if(day >= 1 && day <= de[mon]){
            return true;
    }
    return false;
}
bool checkprim(int n)
{
    int day = n % 100;
    int md = n % 10000;
    if(pri[day] == 1&& pri[md] == 1&& ff(n))
    {
        return true;
    }
    return false;
}
void dfs(int u,int v)
{
    if(u == 8)
    {
        int tt = v;
        if(checkdate(tt) && checkprim(tt))
        {
            ans++;
        }
        return;
    }
    if(s[u] == '-')
    {
        for(int i=0;i<=9;i++)
        {
            int r = v * 10 + i;
            dfs(u+1,r);
        }
    }else
    {
        dfs(u+1,v*10+(s[u] - '0'));
    }
}
void solve()
{
    cin>>s;
    ans = 0;
    if(cnt == 8)
    {
        cout<<"55157";
    }else
    {
        dfs(0,0);
        cout<<ans;
    }
}
int main()
{
    ios
    for(int i=2;i<=1240;i++)
    {
        if(pri[i] == 0)
        {
            pri[i] = 1;
            for(int j=i+i;j<=1240;j+=i)
            {
                pri[j] = -1;
            }
        }
    }
    int t;
    cin>>t;
    while(t --)
    {
        solve();
        cout<<endl;
    }
    return 0;
}

总结:此题用普通dfs会TLE,我们选择对其进行优化,主要优化的地方有2个,一个是使用欧拉筛的思想先把需要判断的素数都存在数组里,需要判断时直接O(1)询问可以大大减少时间,第二个是对日期的判断,通过判断闰年的方法可以排除是素数,减少使用试除法判断素数的次数。

二、P1434 [SHOI2002] 滑雪

题目描述

Michael 喜欢滑雪。这并不奇怪,因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael 想知道在一个区域中最长的滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。下面是一个例子:

1   2   3   4   5
16  17  18  19  6
15  24  25  20  7
14  23  22  21  8
13  12  11  10  9

一个人可以从某个点滑向上下左右相邻四个点之一,当且仅当高度会减小。在上面的例子中,一条可行的滑坡为 24 − 17 − 16 − 1 24-17-16-1 24−17−16−1(从 24 24 24 开始,在 1 1 1 结束)。当然 25 25 25- 24 24 24- 23 23 23- … \ldots …- 3 3 3- 2 2 2- 1 1 1 更长。事实上,这是最长的一条。

输入格式

输入的第一行为表示区域的二维数组的行数 R R R 和列数 C C C。下面是 R R R 行,每行有 C C C 个数,代表高度(两个数字之间用 1 1 1 个空格间隔)。
输出格式

输出区域中最长滑坡的长度。

样例1:

5 5
1 2 3 4 5
16 17 18 19 6
15 24 25 20 7
14 23 22 21 8
13 12 11 10 9

样例输出1

25

提示

对于 100 % 100\% 100% 的数据, 1 ≤ R , C ≤ 100 1\leq R,C\leq 100 1≤R,C≤100。

三、The Lakes

题面翻译

给定 n × m n\times m n×m 的矩阵,正整数上、下、左、右相连构成一个连通块。定义一个连通块的权值为该连通块中所有数的和。求矩阵中最大的连通块。

题目描述

You are given an n × m n \times m n×m grid a a a of non-negative integers. The value a i , j a_{i,j} ai,j​ represents the depth of water at the i i i -th row and j j j -th column.

A lake is a set of cells such that:

  • each cell in the set has a i , j > 0 a_{i,j} > 0 ai,j​>0 , and
  • there exists a path between any pair of cells in the lake by going up, down, left, or right a number of times and without stepping on a cell with a i , j = 0 a_{i,j} = 0 ai,j​=0 .

The volume of a lake is the sum of depths of all the cells in the lake.

Find the largest volume of a lake in the grid.

输入格式

The first line contains a single integer t t t ( 1 ≤ t ≤ 1 0 4 1 \leq t \leq 10^4 1≤t≤104 ) — the number of test cases.

The first line of each test case contains two integers n , m n, m n,m ( 1 ≤ n , m ≤ 1000 1 \leq n, m \leq 1000 1≤n,m≤1000 ) — the number of rows and columns of the grid, respectively.

Then n n n lines follow each with m m m integers a i , j a_{i,j} ai,j​( 0 ≤ a i , j ≤ 1000 0 \leq a_{i,j} \leq 1000 0≤ai,j​≤1000 ) — the depth of the water at each cell.

It is guaranteed that the sum of n ⋅ m n \cdot m n⋅m over all test cases does not exceed 1 0 6 10^6 106 .

输出格式

For each test case, output a single integer — the largest volume of a lake in the grid.

样例输入 1

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

样例输出1

10
0
7
16
21

代码

#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;
typedef long long LL;
#define ios ios::sync_with_stdio(0); cin.tie(0),cout.tie(0);
const int N = 3010;
int ans;
int a[N][N];
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
int n,m;
void dfs(int u,int v)
{
	ans += a[u][v];
	a[u][v] = 0;
    for(int i = 0;i < 4;i++)
    {
        int x = dx[i] + u;
        int y = dy[i] + v;
        if(x <= 0 || x > n || y <= 0 || y > m || !a[x][y]) continue;
        if(a[x][y]) ans += a[x][y];
        a[x][y] = 0;
        dfs(x,y);
    }
}
void solve()
{
	int res = 0;
	cin>>n>>m;
	for(int i = 1;i <= n;i ++)
	{
		for(int j = 1;j <= m;j ++)
		{
			cin>>a[i][j];
		}
	}
	for(int i = 1;i <= n;i ++)
	{
		for(int j = 1;j <= m;j ++)
		{
			if(a[i][j])
			{
				ans = 0;
				dfs(i,j);
				res = max(res,ans);
			}
		}
	}
	cout<<res;
}
int main()
{
    ios
    int _;
    cin>>_;
    while(_--)
    {
        solve();
        cout<<endl;
    }
    return 0;
}

总结:由于有多个输入,所以不能使用memset函数,否则会严重TLE,我想到了一种很好的优化方式,已知二维数组中所有不为0的位置都会走一遍,所以在走过每个位置的时候,把这个位置赋值为0,这样再遍历完所有的位置之后,数组也就转变成为没有初始化的状态。

四、Gold Rush

题意简述
本题有 t t t 组数据。对于每组数据,你都会得到 n n n 个金币。

现在,你可以对这 n n n 个金币进行分堆。每次分堆只能分成两堆,并且需要使分堆后的一堆恰好是另一堆的两倍。同时,分成的两堆都必须有整数个金币。

请你判断:在经过多次或不经过分堆后能否有任意一堆的金币数为 m m m。如果可以,请输出 YES 或其它任意的大小写形式;否则,请输出 NO 或其它任意的大小写形式。

样例解释
对于样例一中的第一组数据,我们可以采用如图的形式分堆:

对于第二组数据,它可以采用如下的分堆方式:

{ 9 } → { 6 , 3 } → { 4 , 2 , 3 } \{\color{red}9\color{black}\}\to\{\color{red}6\color{black},3\}\to\{4,2,3\} {9}→{6,3}→{4,2,3}

在每次分堆前,被分开的堆被标为红色。

对于第三组数据,我们无法进行分堆操作。

对于第四组数据,我们不能把少的金币变成更多的一堆。

题目描述

Initially you have a single pile with n n n gold nuggets. In an operation you can do the following:

  • Take any pile and split it into two piles, so that one of the resulting piles has exactly twice as many gold nuggets as the other. (All piles should have an integer number of nuggets.)


    One possible move is to take a pile of size 6 6 6 and split it into piles of sizes 2 2 2 and 4 4 4 , which is valid since 4 4 4 is twice as large as 2 2 2 .

Can you make a pile with exactly m m m gold nuggets using zero or more operations?

输入格式

The first line contains an integer t t t ( 1 ≤ t ≤ 1000 1 \leq t \leq 1000 1≤t≤1000 ) — the number of test cases.

The only line of each test case contains two integers n n n and m m m ( 1 ≤ n , m ≤ 1 0 7 1 \leq n, m \leq 10^7 1≤n,m≤107 ) — the starting and target pile sizes, respectively.

输出格式

For each test case, output “YES” if you can make a pile of size exactly m m m , and “NO” otherwise.

样例 #1

11
6 4
9 4
4 2
18 27
27 4
27 2
27 10
1 1
3 1
5 1
746001 2984004

样例输出 #1

YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
NO

提示

The first test case is pictured in the statement. We can make a pile of size 4 4 4 .

In the second test case, we can perform the following operations: { 9 } → { 6 , 3 } → { 4 , 2 , 3 } \{\color{red}{9}\} \to \{\color{red}{6},3\} \to \{4,2,3\} {9}→{6,3}→{4,2,3} . The pile that is split apart is colored red before each operation.

In the third test case, we can’t perform a single operation.

In the fourth test case, we can’t end up with a larger pile than we started with.

代码

#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;
typedef long long LL;
#define ios ios::sync_with_stdio(0); cin.tie(0),cout.tie(0);
const int N = 2e5+10;
bool dfs(int a,int b)
{
    if(a == b) return true; //如果相等 则目标达成
    if(a%3!=0 || a < b) return false; //如果要分出2:1的比例 则至少要被三整除
    /*下一个状态有两种情况,二者有一个成立即可
    	1.一个是1/3的情况 (a/3)
    	2.一个是2/3的情况 (a - a/3)
    */
    return dfs(a/3,b) || dfs(a - a/3,b); 
}
void solve()
{
    int a,b;
    cin>>a>>b;
    if(dfs(a,b)) cout<<"YES";
    else cout<<"NO";
}
int main()
{
    ios
    int _;
    cin>>_;
    while(_--)
    {
        solve();
        cout<<endl;
    }
    return 0;
}

总结:在某些题目中,dfs可以搜索多种情况的不同状态

五、Fall Down

题面翻译

有一个 n × m n\times m n×m 的网格( 1 ≤ n , m ≤ 50 1 \leq n, m \leq 50 1≤n,m≤50),其中每个格子上有三种情况:

  1. o字符:此块为一个石子
  2. *字符:此块为障碍物,石子不能通过。
  3. .字符:此块为空,石子可以通过。

每块石子回往下落,直到它落在了网格最下面一行、障碍物的上面一格或已落下的石子上面一格

给出原式网格,求石子落下后的网格。

题目描述

There is a grid with n n n rows and m m m columns, and three types of cells:

  • An empty cell, denoted with ‘.’.
  • A stone, denoted with ‘*’.
  • An obstacle, denoted with the lowercase Latin letter ‘o’.

All stones fall down until they meet the floor (the bottom row), an obstacle, or other stone which is already immovable. (In other words, all the stones just fall down as long as they can fall.)

Simulate the process. What does the resulting grid look like?

输入格式

The input consists of multiple test cases. The first line contains an integer t t t ( 1 ≤ t ≤ 100 1 \leq t \leq 100 1≤t≤100 ) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers n n n and m m m ( 1 ≤ n , m ≤ 50 1 \leq n, m \leq 50 1≤n,m≤50 ) — the number of rows and the number of columns in the grid, respectively.

Then n n n lines follow, each containing m m m characters. Each of these characters is either ‘.’, ‘*’, or ‘o’ — an empty cell, a stone, or an obstacle, respectively.

输出格式

For each test case, output a grid with n n n rows and m m m columns, showing the result of the process.

You don’t need to output a new line after each test, it is in the samples just for clarity.

样例输入 #1

3
6 10
.*.*....*.
.*.......*
...o....o.
.*.*....*.
..........
.o......o*
2 9
...***ooo
.*o.*o.*o
5 5
*****
*....
*****
....*
*****

样例输出 #1

..........
...*....*.
.*.o....o.
.*........
.*......**
.o.*....o*

....**ooo
.*o**o.*o

.....
*...*
*****
*****
*****

代码

#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;
typedef long long LL;
#define ios ios::sync_with_stdio(0); cin.tie(0),cout.tie(0);
const int N = 100010,M = 2010,INF = 0x3f3f3f3f;
int gcd(int a,int b){
return b?gcd(b,a%b):a;
}
char a[100][100];
int n,m;
void dfs(int u,int v)
{
    if(a[u+1][v] == 'o' || (u+1) == n || a[u+1][v] == '*')
    {
        return;
    }
    else
    {
        swap(a[u][v],a[u+1][v]);
        dfs(u+1,v);
    }
}
void solve()
{
    cin>>n>>m;
    for(int i = 0;i < n;i ++)
    {
    	for(int j = 0;j < m;j ++)
    	{
    		cin>>a[i][j];
    	}
    }
    for(int i = n-2;i >= 0;i --)
    {
        for(int j = 0;j < m;j ++)
        {
            if(a[i][j] == '*')
            {
                dfs(i,j);
            }
        }
    }
    for(int i = 0;i < n;i ++)
    {
        for(int j = 0;j < m;j ++)
        {
            cout<<a[i][j];
        }
        cout<<endl;
    }
}
int main()
{
    ios
    int t;
    cin>>t;
    while(t --)
    {
        solve();
        cout<<endl;
    }
    return 0;
}

总结:模板题

六、选数

题目描述

已知 n n n 个整数 x 1 , x 2 , ⋯   , x n x_1,x_2,\cdots,x_n x1​,x2​,⋯,xn​,以及 1 1 1 个整数 k k k( k < n k<n k<n)。从 n n n 个整数中任选 k k k 个整数相加,可分别得到一系列的和。例如当 n = 4 n=4 n=4, k = 3 k=3 k=3, 4 4 4 个整数分别为 3 , 7 , 12 , 19 3,7,12,19 3,7,12,19 时,可得全部的组合与它们的和为:

3 + 7 + 12 = 22 3+7+12=22 3+7+12=22

3 + 7 + 19 = 29 3+7+19=29 3+7+19=29

7 + 12 + 19 = 38 7+12+19=38 7+12+19=38

3 + 12 + 19 = 34 3+12+19=34 3+12+19=34

现在,要求你计算出和为素数共有多少种。

例如上例,只有一种的和为素数: 3 + 7 + 19 = 29 3+7+19=29 3+7+19=29。

输入格式

第一行两个空格隔开的整数 n , k n,k n,k( 1 ≤ n ≤ 20 1 \le n \le 20 1≤n≤20, k < n k<n k<n)。

第二行 n n n 个整数,分别为 x 1 , x 2 , ⋯   , x n x_1,x_2,\cdots,x_n x1​,x2​,⋯,xn​( 1 ≤ x i ≤ 5 × 1 0 6 1 \le x_i \le 5\times 10^6 1≤xi​≤5×106)。

输出格式

输出一个整数,表示种类数。

样例输入 #1

4 3
3 7 12 19

样例输出 #1

1

代码

#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;
typedef long long LL;
#define ios ios::sync_with_stdio(0); cin.tie(0),cout.tie(0);
const int N = 100010,M = 2010,INF = 0x3f3f3f3f;
int gcd(int a,int b){
return b?gcd(b,a%b):a;
}
int a[N];
int ans = 0;
int n,m;
bool ff(int n)
{
	if(n < 2) return 0;
	for(int i = 2;i <= n / i;i ++)
	{
		if(n % i == 0) return 0;
	}
	return 1;
}
void dfs(int u,int v,int k)
{
	if(u == m)
	{
		if(ff(v))
		{
			ans ++;
		}
		return ;
	}
	for(int i = k;i < n;i ++)
	{
		dfs(u+1,v+a[i],i + 1);
	}
}
void solve()
{
	cin>>n>>m;
	for(int i = 0;i < n;i ++) cin>>a[i];
	dfs(0,0,0);
	cout<<ans;
}
int main()
{
    ios
    solve();
    return 0;
}

总结:模板题

7系列ZYNQ硬件调试:Vitis无法识别ARM DAP的排查与解决 本文详细分析了Xilinx 7系列ZYNQ芯片在Vitis开发环境中无法识别ARM DAP的常见问题及解决方案。从硬件设计检查(电源系统、时钟电路)、JTAG连接诊断到软件环境排查,提供了全面的调试指南。特别针对ARM DAP初始化失败的情况,给出了实用的排查步骤和预防措施,帮助开发者快速定位和解决类似问题。 阅读详情

相关推荐

SAP成本核算变式OKKN配置详解:从CK11N到CK24,手把手教你搞定标准成本发布

本文深入解析SAP成本核算变式OKKN的配置原理与实战应用,涵盖从CK11N到CK24的标准成本发布全流程。详细讲解数量结构控制、价值结构配置及间接费用计算规则,帮助成本会计精准掌握标准成本计算逻辑,解决BOM版本选择、工艺路线获取等常见问题,提升企业成本管理效率。

weixin_27219587的博客 299

Avoid The Lakes

Avoid The Lakes Farmer John’s farm was flooded in the most recent storm, a fact only aggravated by the information that his cows are deathly afraid of water. His insurance agency will only repay him, ...

leihao-lester 229

AOSP14 Launcher3——手势上滑关键类AbsSwipeHandler解析

通过精密的事件监听、状态管理和对系统动画 API 及 Launcher 内部组件的协调,实现了复杂而流畅的手势导航体验。它的抽象设计允许子类(如。是 Quickstep (Launcher3 的手势导航实现) 中处理。的核心逻辑抽象基类。这个非常核心且复杂的类。)定制特定的回家动画逻辑。好的,我们来深入分析。

Micheal_Yang's Blog 1526

洛谷 P5440 【XR-2】奇迹

思路 直接构造数据 构造完数据 看一眼ans里面 五万个数 T<10 即最多五十万*8次操作。接着检查闰年的2月29号 检查该八位数是否为质数 如果是存入ans数组。最后 检查常规日期 如果遇到质数日期存入ans数组。读逐次判断每一位上的数字是否与答案数组中的数字一样。先构造月日均为质数的组合存入 a数组 中。直接加上计数器加上flag这个1;如果所有一样则flag=1;

2301_78763076的博客 607

不用U盘也能装Ubuntu?手把手教你用EasyUEFI搞定双系统(附企业版资源)

本文详细介绍了无需U盘即可安装Ubuntu双系统的方法。通过使用EasyUEFI工具,在Windows环境下创建虚拟启动分区并配置UEFI引导,即可直接从硬盘启动Ubuntu安装程序。该方法特别适合开发者或技术爱好者快速搭建Linux开发环境,操作安全便捷,无需额外物理介质。

weixin_29215391的博客 291

[Stanford CS217]CUDA中矩阵乘法GEMM优化的最关键点:向量内积和向量外积分别取行和取列

对于矩阵C中的每一个tile,矩阵A与矩阵B中的tile只需要读取一次,这样就可以达到 O(N) 的计算强度。理想情况下性能应当受限于算术吞吐量,确切来说对于一个大型方阵,即 M=N=K ,矩阵乘法的数学操作复杂度为 O(N3) ,而数据量为 O(N2) ,同时计算强度为 N (这里的计算强度可以被理解为同一个数据被重复利用的次数)。GEMM就是指计算 C=A∗B+C ,其中 A 、B和C都是矩阵,A是 M×K 的矩阵,B是 K×N 的矩阵, C是 M×N 的矩阵。这就是向量内积和向量外积的最大区别。

weixin_55035144的博客 1444

Avoid The Lakes(避开湖泊C++)

Farmer John’s farm was flooded in the most recent storm, a fact only aggravated by the information that his cows are deathly afraid of water. His insurance agency will only repay him, however, an amount depending on the size of the largest “lake” on his fa

qq_65039825的博客 598

第三节: 串口通信(用CubeMX学习STM32)

用CubeMX学习STM32, 串口通信学习, 通过轮询方式和中断方式两种方式进行通信演示。 STM32F407zgt6

Kevin_8_Lee的博客 8909

【DFS深度优先搜索】【欧拉筛法】【洛谷P5540】

细节+框架+合理化分析

ZzzhuiyizzZ的博客 353

华为OD机考真题 新系统 - 数列求值(Java/Py/C/C++/Js/Go)

华为OD机试真题 新系统【数列求值】,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。华为OD机试真题 【数列求值】多语言题解。

qq_45776114的博客 674

目标检测YOLO实战应用案例100讲-跨模态、多级别融合的RGB-D显著目标检测方法研究(续)

在第二章介绍了本研究的跨模态特征融合方法,第二章对于多级别特征的融合, 使用的是与基线模型baseline相同的方法:相邻级别的特征中,高级特征进行上采 样到与低级特征相同的尺度,再将高级特征通过降维得到与低级特征相同的通道数 量,最后对二者进行特征叠加,如此自顶向下的进行多级别的特征融合。本章主要 介绍本研究在特征层面的另一发现,并基于此发现引出的本文的第二个创新点:多 级别特征的融合方法。另外,在网络最深层,本文设计了一个新的模块来获取大的 感受野,对于大尺度目标能够增加更多语义信息,提升检测效果。 骨

qq_36130719的博客 481

算法训练营 Day1

是一个内置的高阶函数,它的主要作用是对可迭代对象(如列表、元组等)中的每个元素应用指定的函数,并返回一个迭代器,该迭代器会生成函数应用后的结果。给你⼀个数组 nums 和⼀个值 val ,你需要 原地 移除所有数值等于 val 的元素,并返回移除后数组的新⻓度。给你⼀个 升序排列 的数组 nums ,请你 原地 删除重复出现的元素,使每个元素 只出现⼀次 ,返回删除后数组的。将不重复的元素放入数组的前面,并返回新变量的值,即为最终删除数组后的剩余数量。你不需要考虑数组中超出新⻓度后⾯的元素。

m0_73983707的博客 1300

[QMT量化交易小白入门]-十二、QMT回测龙头打首板和连板的策略

class a():passA = a() #创建空的类的实例 用来保存委托状态field_list定义了需要的市场数据字段,而类a用于保存交易状态。

木头大左的博客 4768

算法训练营打卡-Day1

双指针的做法还要多去做一些题目,多看多练,自然后面就能够反映过来了。

m0_59373342的博客 189

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

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

C++算法训练营 Day1 数组基础

坚持每日更新三道~

m0_70524224的博客 882

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

代码随想录算法训练DAY1 二分查找和移除元素

记录一下算法学习之路

whhmatlab的博客 2041

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

代码随想录 算法训练 Day1:数组

示例 1: 给定 nums = [3,2,2,3], val = 3, 函数应该返回新的长度 2, 并且 nums 中的前两个元素均为 2。示例 2: 给定 nums = [0,1,2,2,3,0,4,2], val = 2, 函数应该返回新的长度 5, 并且 nums 中的前五个元素为 0, 1, 3, 0, 4。给定一个 n 个元素有序的(升序)整型数组 nums 和一个目标值 target ,写一个函数搜索 nums 中的 target,如果目标值存在返回下标,否则返回 -1。元素的顺序可以改变。

weixin_48885322的博客 350

算法训练营第66期-day1

针对第一点其实显而易见,第二点则是因为middle一定不是target,所以right=middle-1 (闭区间--right是可以取到的值,如果right == middle则扩大了范围,因为middle他一定不是target)第二点类似,right是开区间取不到,所以right== middle默认了接下来的查找区间是[left,middle),而middle本身就是取不到的。主要就是看right在边界有没有意义。

W94789888的博客 192

算法训练营DAY1 第一章 数组part01

解题思路:设置两个指针,一快一慢,快指针用于遍历数组,慢指针用于更新数组;每次循环中只要快指针处的值不是要剔除的值,就将这个值赋给慢指针处;当遇到需要剔除的值则不赋值且慢指针不自增。解题思路:新建一个数组,从后方前赋值,选取平方更大的赋值;i,j作为原数组的首位置与尾位置指针,用于比较平方的大小。解题思路:设置一个左下标和右下标,以及中间下标。比较中间值与目标值从而更新新的下标。区间的定义就是不变量,那么在循环中坚持根据查找区间的定义来做边界处理,就是。要始终坚持根据查找区间的定义来做边界处理。

2401_89133587的博客 299

代码随想录算法训练营Day1 | 二分查找、移除元素、有序数组的平方

来了来了,报名参加了11月的算法训练营,全长两个月,蒟蒻的研一新生为了就业而奋斗(不是实际是:从训练营寻找到了push动力 😃。

SapientialM的成长历程 1316

算法训练营 Day1-数组 1 | 二分查找 | 移除元素 | 有序数组的平方

二分查找:注意区间定义和边界条件。移除元素:双指针法的应用。有序数组的平方:双指针法优化排序。本期能够非常直观的感受到快慢指针的灵魂,下期再见~

2401_84085652的博客 1638

算法训练营day1

二分查找和双指针算法

weixin_51677555的博客 872

算法训练营-day1

二分查找的前提是数组是有序的,同时要求数组的元素是不重复的,一旦数组中的元素有重复,则返回的下标值不是唯一的。数组的元素在内存地址中是连续的,不能单独删除数组中的某个元素,只能覆盖,提供两种解法,一种是使用两层for循环进行暴力求解;双指针法(快慢指针法)在数组和链表的操作中是非常常见的,很多考察数组、链表、字符串等操作的面试题,都使用双指针法。关键在于找到正数与负数的分界线,这样就回得到两个有序的数组,可以利用归并排序的思想,得到一个递增的数组。二分法的时间复杂度为:O(log n)时间复杂度:O(n)

m0_58432829的博客 728

笔试算法训练day1

作者是大三计科学生一枚,分享一下自己每天的做题记录,会尽量分享自己觉得质量高的题目,希望能够帮助到大家

wyhplus的博客 641

算法训练Day1

算法小白坚持训练的第一天!

CodeKiller123的博客 440

代码随想录算法训练营 Day1 数组 二分法 双指针

二分法前提是顺序数组,取中比较即可。

weixin_43679621的博客 316
上一篇: Codeforces Round 867 (Div. 3)比赛总结
下一篇: 算法训练 DAY-2
唯念月色凉_
博客等级 码龄7年 13粉丝 6原创
评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

唯念月色凉_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值