暑假集训内容

离散化思想:

    有时数据范围很大时直接用哈西数组开不了,就要用离散化思想;

去重函数:unique()  STL里自带函数,返回去重后的尾地址。

lower_bound();

upper_bound();

前缀和:

        应用与树状数组。

剪枝:

          在搜索时可能会重复搜索,这时就要用到剪枝来减低时间复杂度;

   大多数情况:边界,最优 ,记忆化搜索,顺序。

BFS 大多用来找最优解,DFS大多来找可行性。

记忆化搜索题目:https://vjudge.net/contest/238941#problem/E(暑假第三天)。

三分:

       三分题目:https://vjudge.net/contest/239160。(题解另写)

     三分发要求:必须要单调。

动态规划:

    错排公式: f(n)=(n-1)*(f(n-1)+f(n-2))。

(1)描述优解的结构特征。 

(2)递归地定义一个最优解的值。 

(3)自底向上计算一个最优解的值。

(4)从已计算的信息中构造一个最优解。

相关题目:https://vjudge.net/contest/239160。

有一只经过训练的蜜蜂只能爬向右侧相邻的蜂房,不能反向爬行。请编程计算蜜蜂从蜂房a爬到蜂房b的可能路线数。
其中,蜂房的结构如下所示。
 
Input
输入数据的第一行是一个整数N,表示测试实例的个数,然后是N 行数据,每行包含两个整数a和b(0<a<b<50)。
Output
对于每个测试实例,请输出蜜蜂从蜂房a爬到蜂房b的可能路线数,每个实例的输出占一行。
Sample Input
2
1 2
3 6
Sample Output
1
3

AC代码:

#include <iostream>
#include<algorithm>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<deque>
#include<queue>
#include<vector>
#include<stack>
#include<ctime>
using namespace std;
int main()
{
    long long int a[100];

    a[1]=a[2]=1;
    for(int i=3;i<100;i++)
        a[i]=a[i-1]+a[i-2];
        int T;
        cin>>T;
    while(T--)
    {
        int x,y;
        cin>>x>>y;
        cout<<a[y-x+1]<<endl;;
    }
}

今年的ACM暑期集训队一共有18人,分为6支队伍。其中有一个叫做EOF的队伍,由04级的阿牛、XC以及05级的COY组成。在共同的集训生活中,大家建立了深厚的友谊,阿牛准备做点什么来纪念这段激情燃烧的岁月,想了一想,阿牛从家里拿来了一块上等的牛肉干,准备在上面刻下一个长度为n的只由"E" "O" "F"三种字符组成的字符串(可以只有其中一种或两种字符,但绝对不能有其他字符),阿牛同时禁止在串中出现O相邻的情况,他认为,"OO"看起来就像发怒的眼睛,效果不好。

你,NEW ACMer,EOF的崇拜者,能帮阿牛算一下一共有多少种满足要求的不同的字符串吗?

PS: 阿牛还有一个小秘密,就是准备把这个刻有 EOF的牛肉干,作为神秘礼物献给杭电五十周年校庆,可以想象,当校长接过这块牛肉干的时候该有多高兴!这里,请允许我代表杭电的ACMer向阿牛表示感谢!

再次感谢!
Input
输入数据包含多个测试实例,每个测试实例占一行,由一个整数n组成,(0<n<40)。
Output
对于每个测试实例,请输出全部的满足要求的涂法,每个实例的输出占一行。
Sample Input
1
2
Sample Output
3
8

#include <iostream>
#include<algorithm>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<deque>
#include<queue>
#include<vector>
#include<stack>
#include<ctime>
using namespace std;
int main()
{
    long long int a[100][4];
    for(int i=1;i<4;i++)
        a[1][i]=1;
    for(int i=2;i<100;i++)
    {
        a[i][1]=a[i-1][1]+a[i-1][2]+a[i-1][3];
        a[i][2]=a[i-1][1]+a[i-1][2]+a[i-1][3];
        a[i][3]=a[i-1][1]+a[i-1][2];
    }
    int n;
    while(cin>>n!=NULL)
        cout<<a[n][1]+a[n][2]+a[n][3]<<endl;


}

尺取:

(不再细说,放几个例题)

A sequence of N positive integers (10 < N < 100 000), each of them less than or equal 10000, and a positive integer S (S < 100 000 000) are given. Write a program to find the minimal length of the subsequence of consecutive elements of the sequence, the sum of which is greater than or equal to S.
Input
The first line is the number of test cases. For each test case the program has to read the numbers N and S, separated by an interval, from the first line. The numbers of the sequence are given in the second line of the test case, separated by intervals. The input will finish with the end of file.
Output
For each the case the program has to print the result on separate line of the output file.if no answer, print 0.
Sample Input
2
10 15
5 1 3 5 10 7 4 9 2 8
5 11
1 2 3 4 5
Sample Output
2
3

#include <iostream>
#include<algorithm>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<deque>
#include<queue>
#include<vector>
#include<stack>
#include<ctime>
using namespace std;
int main()
{
    int T;
    cin>>T;
    while(T--)
    {
        int a[100010],n,m,b[100010];
        cin>>n>>m;
        for(int i=0; i<n; i++)
            cin>>a[i];
        int x=0,y=1,p=0;
        int z=a[0];
        while(y<n||x<n)
        {
            if(z==m)
            {
                b[p++]=y-x;
                if(y<n)
                    z+=a[y]-a[x],
                       y++,
                       x++;
                else
                {
                    z-=a[x];
                    x++;
                }
            }
            if(z>m)
            {
                b[p++]=y-x;
                z-=a[x];
                x++;
            }

            if(z<m)
            {
                if(y<n)
                {
                    z+=a[y];
                    y++;

                }
                else
                    break;
            }

        }
        if(p)
        sort(b,b+p),
        cout<<b[0]<<endl;
        else
        {
            cout<<"0"<<endl;
        }
    }

}

 

基于STM32F407,使用DFS算法实现最短迷宫路径检索,分为三种模式:1.DEBUG模式,2. 训练模式,3. 主程序模式 ,DEBUG模式主要分析bug,测量必要数据,训练模式用于DFS算法训练最短路径,并将最短路径以链表形式存储Flash, 主程序模式从Flash中….zip项目工程资源经过严格测试可直接运行成功且功能正常的情况才上传,可轻松复刻,拿到资料包后可轻松复现出一样的项目,本人系统开发经验充足(全领域),有任何使用问题欢迎随时与我联系,我会及时为您解惑,提供帮助。 【资源内容】:包含完整源码+工程文件+说明(如有)等。答辩评审平均分达到96分,放心下载使用!可轻松复现,设计报告也可借鉴此项目,该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的。 【提供帮助】:有任何使用问题欢迎随时与我联系,我会及时解答解惑,提供帮助 【附带帮助】:若还需要相关开发工具、学习资料等,我会提供帮助,提供资料,鼓励学习进步 【项目价值】:可用在相关项目设计中,皆可应用在项目、毕业设计、课程设计、期末/期中/大作业、工程实训、大创等学科竞赛比赛、初期项目立项、学习/练手等方面,可借鉴此优质项目实现复刻,设计报告也可借鉴此项目,也可基于此项目来扩展开发出更多功能 下载后请首先打开README文件(如有),项目工程可直接复现复刻,如果基础还行,也可在此程序基础上进行修改,以实现其它功能。供开源学习/技术交流/学习参考,勿用于商业用途。质量优质,放心下载使用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值