The 12th Zhejiang Provincial Collegiate Programming Contest

3个PLC进阶教程实战项目,学完立即接私单! 此处应插入清晰的硬件电路图,包含土壤湿度传感器、水泵、PLC的输入输出端子,并标注清晰的接线方式。同样的,也需要插入清晰的梯形图,用简单的逻辑表达控制过程,比如:土壤湿度传感器信号低于设定值 -> PLC输出信号 -> 水泵启动。我是老王,一个在自动化行业摸爬滚打多年的老工程师,今天咱们不聊那些枯燥的理论,直接上手三个PLC进阶实战项目,学完保证你信心满满,立马就能接私单!想想你家里的空调,它也是通过检测室温,并根据设定的温度进行制冷或制热,这个项目就是类似的原理。 阅读详情

A - Ace of Aces

题意:数字代表选的那个人,票数最多的当选,如果出现最高票有多个人,否则输出Nobody

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<string.h>
#include<stdlib.h>
#include<cstdio>
#include<cstdlib>
#include<queue>
#define mod 1e9+7
#define ll long long
#define MAXSIZE 100005
int a[1005];
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        memset(a,0,sizeof(a));
        for(int i=0;i<n;i++){
            int x;
            cin>>x;
            a[x]++;
        }
        int maxnum=0,pos,flag=0;
        for(int i=1;i<=1000;i++){
            if(a[i]>maxnum){
                maxnum=a[i];
                pos=i;
            }
        }
        for(int i=1;i<=1000;i++){
            if(a[i]==maxnum&&pos!=i){
                flag=1;
                break;
            }
        }
        if(flag)
            cout<<"Nobody"<<endl;
        else cout<<pos<<endl;
    }
    return 0;
}


B - Team Formation

题意:每个人都有各自的能力值,如果两个人的能力值异或之后大于他俩,那么就是一个成功的配对,求总配对数.关键点就是开出数组来保存他们二进制中第一个1的位置,然后每次比较较小的数中的第一个1位置在较大数中对应位的异或值,

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<string.h>
#include<stdlib.h>
#include<cstdio>
#include<cstdlib>
#include<queue>
#define mod 1e9+7
#define ll long long
#define MAXSIZE 100005
int a[100005];
int pos[100005];//最高位
int b[35];//某最高位的个数
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n,ans=0;
        cin>>n;
        memset(b,0,sizeof(b));
        for(int i=0; i<n; i++)
            cin>>a[i];
        sort(a,a+n);
        for(int i=0; i<n; i++)
        {
            for(int j=31; j>=0; j--)
            {
                if(a[i]&(1<<j))
                {
                    pos[i]=j;
                    b[j]++;
                    break;
                }
            }
        }
        for(int i=0; i<n; i++)
        {
            int j=pos[i];
            while(j>=0)
            {
                if(!(a[i]&(1<<j)))
                    ans+=b[j];
                j--;
            }
            //cout<<ans<<endl;
        }
        cout<<ans<<endl;
    }
    return 0;
}

C- Convex Hull(凸包)

挖坑待填

D - Beauty of Array

题意:给出一串数组,取其中连续子串,元素求和就是该数字串的beauty值.求整体beauty值.

关键在于记录数字位置,当一个数未出现过,那么这个数对先前所有子串都有贡献(也就是可以在先前所有字串中加入这一元素),如果出现过,那么只对当前位置与先前位置之间的子串有贡献.

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<string.h>
#include<stdlib.h>
#include<cstdio>
#include<cstdlib>
#include<queue>
#define mod 1e9+7
#define ll long long
#define MAXSIZE 100005

int a[1000005];
int numpos[1000005];
ll int temp[1000005];
using namespace std;
int main()
{
    int t,n;
    cin>>t;
    while(t--)
    {
        ll ans=0;
        memset(numpos,-1,sizeof(numpos));
        cin>>n;
        for(int i=0;i<n;i++)
            cin>>a[i];
        for(int i=0;i<n;i++){
                ans+=a[i];
            if(numpos[a[i]]==-1){
                numpos[a[i]]=i;
                ans+=a[i]*i;
            }
            else {
                ans+=a[i]*(i-numpos[a[i]]-1);
                numpos[a[i]]=i;
            }
            temp[i]=ans;
        }
        ans=0;
        for(int i=0;i<n;i++)
            ans+=temp[i];
        cout<<ans<<endl;
    }

    return 0;
}

E - Floor Function

这道题题解暂时还未找到

F - Permutation Graph

挖坑待填

G - Lunch Time

题意:有三种,每种选一个中等价格的.求价格总和,再输出各个菜,其实就是定义结构,然后排序,直接定位出中位数

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<map>
#define mod 1e9+7
#define ll long long
#define MAXSIZE 100005
struct Node
{
    char s[60];
    int num;
}x[120],y[120],z[120];
bool cmp(Node a,Node b)
{
    return a.num < b.num;
}
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        memset(x,0,sizeof(x));
        memset(y,0,sizeof(y));
        memset(z,0,sizeof(z));
        int s,m,d;
        int total;
        cin>>s>>m>>d;
        for(int i=0;i<s;++i)
            cin>>x[i].s>>x[i].num;
        sort(x,x+s,cmp);
        for(int i=0;i<m;++i)
            cin>>y[i].s>>y[i].num;
        sort(y,y+m,cmp);
        for(int i=0;i<d;++i)
            cin>>z[i].s>>z[i].num;
        sort(z,z+d,cmp);
        total = x[s/2].num + y[m/2].num + z[d/2].num;
        cout<<total<<" "<<x[s/2].s<<" "<< y[m/2].s <<" "<< z[d/2].s <<endl;
    }
    return 0;
}
 

H - May Day Holiday

题意:问五一假期有多少天,其实无非就7个答案,然后先算出1928,然后在一年年推,非常快

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<string.h>
#include<stdlib.h>
#include<cstdio>
#include<cstdlib>
#include<map>
#define mod 1e9+7
#define ll long long
#define MAXSIZE 100005

using namespace std;
int day[]={6,9,6,5,5,5,5};

int leap(int y)
{
    if(y%400==0 || (y%4==0&&y%100!=0))
        return 1;
    return 0;
}
int main(){
    int t,n;
    cin>>t;
    while(t--){
        cin>>n;
        int d=2,y=1928;
        if(n==y)
            cout<<day[d]<<endl;
        else {
            while(n>y){
                y++;
                if(leap(y))
                    d+=366;
                else d+=365;
                d%=7;
            }
            cout<<day[d]<<endl;
        }
    }
    return 0;
}


I - Earthstone Keeper

挖坑待填

J - Convert QWERTY to Dvorak

题意:直接map

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<string.h>
#include<stdlib.h>
#include<cstdio>
#include<cstdlib>
#include<map>
#define mod 1e9+7
#define ll long long
#define MAXSIZE 100005
int a[1005];
using namespace std;
int main()
{
    map<char,char>mp;
    mp['_'] = '{';
    mp['-'] = '[';
    mp['+'] = '}';
    mp['='] = ']';
    mp['Q'] = '"';
    mp['q'] = '\'';
    mp['W'] = '<';
    mp['w'] = ',';
    mp['E'] = '>';
    mp['e'] = '.';
    mp['R'] = 'P';
    mp['r'] = 'p';
    mp['T'] = 'Y';
    mp['t'] = 'y';
    mp['Y'] = 'F';
    mp['y'] = 'f';
    mp['U'] = 'G';
    mp['u'] = 'g';
    mp['I'] = 'C';
    mp['i'] = 'c';
    mp['O'] = 'R';
    mp['o'] = 'r';
    mp['P'] = 'L';
    mp['p'] = 'l';
    mp['{'] = '?';
    mp['['] = '/';
    mp['}'] = '+';
    mp[']'] = '=';
    mp['S'] = 'O';
    mp['s'] = 'o';
    mp['D'] = 'E';
    mp['d'] = 'e';
    mp['F'] = 'U';
    mp['f'] = 'u';
    mp['G'] = 'I';
    mp['g'] = 'i';
    mp['H'] = 'D';
    mp['h'] = 'd';
    mp['J'] = 'H';
    mp['j'] = 'h';
    mp['K'] = 'T';
    mp['k'] = 't';
    mp['L'] = 'N';
    mp['l'] = 'n';
    mp[':'] = 'S';
    mp[';'] = 's';
    mp['"'] = '_';
    mp['\''] = '-';
    mp['Z'] = ':';
    mp['z'] = ';';
    mp['X'] = 'Q';
    mp['x'] = 'q';
    mp['C'] = 'J';
    mp['c'] = 'j';
    mp['V'] = 'K';
    mp['v'] = 'k';
    mp['B'] = 'X';
    mp['b'] = 'x';
    mp['N'] = 'B';
    mp['n'] = 'b';
    mp['<'] = 'W';
    mp[','] = 'w';
    mp['>'] = 'V';
    mp['.'] = 'v';
    mp['?'] = 'Z';
    mp['/'] = 'z';

    string s;
    while(getline(cin,s))
    {
        for(int i = 0;i<s.size();++i)
        {
            if(mp.find(s[i]) != mp.end())
                s[i] = mp[s[i]];
        }
        cout<<s<<endl;
    }
    return 0;
}

K - Capture the Flag

题意:模拟

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<string.h>
#include<stdlib.h>
#include<cstdio>
#include<cstdlib>
#include<map>
#define mod 1e9+7
#define ll long long
#define MAXSIZE 100005
using namespace std;
int n,q,p,c;
struct team
{
    int id;
    int ranklist;
    double score;
} a[105];
int vis[105][105][15],defen[105];
bool cmp1(team x,team y){
return x.score>y.score;
}
bool cmp2(team x,team y){
return x.id<y.id;
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d%d%d",&n,&q,&p,&c);
        for(int i=1; i<=n; i++) //初始化
        {
            a[i].id=i;
            a[i].ranklist=1;
            a[i].score=p;
        }
        while(c--)//攻击
        {
            int k;
            memset(vis,0,sizeof(vis));
            scanf("%d",&k);//攻击方式
            while(k--)
            {
                int atk,def,sev;
                scanf("%d%d%d",&atk,&def,&sev);
                if(vis[atk][def][sev])
                    continue;
                vis[atk][def][sev]=1;
            }
            int cnt;
            double av;
            for(int k=1; k<=q; k++)
            {
                for(int j=1; j<=n; j++)
                {
                    cnt=0;
                    for(int i=1; i<=n; i++)//统计攻击
                        if(vis[i][j][k])
                            cnt++;
                    if(cnt==0)
                        continue;
                    a[j].score-=(n-1);
                    av=(n-1)*1.0/cnt;
                    for(int i=1; i<=n; i++)//加回去
                        if(vis[i][j][k])
                            a[i].score+=av;
                }
            }
            int z;
            for(int i=1; i<=q; i++)//每个服务器防御
            {
                memset(defen,0,sizeof(defen));
                cnt=0;
                for(int j=1; j<=n; j++)//每个队伍
                {
                    scanf("%d",&z);
                    if(z==1)
                    {
                        defen[j]=1;//有防御的标记,统计
                        cnt++;
                    }
                    else
                    {
                        defen[j]=0;//没防御的直接减掉
                        a[j].score-=(n-1);
                    }
                }
                if(cnt==n)
                    continue;
                av=(n-1)*1.0/cnt;
                av=av*(n-cnt);
                for(int j=1; j<=n; j++)//加上去
                {
                    if(defen[j])
                        a[j].score+=av;
                }
            }
            sort(a+1,a+1+n,cmp1);//按分数排名定rank
            a[1].ranklist=1;
            for(int j=2;j<=n;j++){
                if(fabs(a[j].score-a[j-1].score)<0.000001)
                    a[j].ranklist=a[j-1].ranklist;
                else a[j].ranklist=j;
            }
            sort(a+1,a+1+n,cmp2);//按id排名给出询问结果
            int ques,ask;
            scanf("%d",&ques);
            for(int j=0;j<ques;j++){
                scanf("%d",&ask);
                printf("%.10lf %d\n",a[ask].score,a[ask].ranklist);
            }
        }
    }
return 0;
}

L - Demacia of the Ancients

题意:找大于6000的数

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<string.h>
#include<stdlib.h>
#include<cstdio>
#include<cstdlib>
#include<queue>
#define mod 1e9+7
#define ll long long
#define MAXSIZE 100005
using namespace std;
int main()
{
    int t;
    cin >>t;
    while(t--)
    {
        int n,x;
        int ans = 0;
        scanf("%d",&n);
        for(int i = 0;i<n;++i)
        {
            scanf("%d",&x);
            if(x > 6000)
                ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}







[UVM]UVM TLM2.0简介及应用实例分析 本文介绍了TLM2.0在UVM中的实现与应用。TLM2.0作为SystemC模型间的核心传输机制,相比TLM1.0提供了更丰富的特性,包括双向阻塞/非阻塞接口、时间标记和统一数据包。文章详细解析了TLM2.0在UVM中的接口实现方式,包括socket类型定义、数据传输机制以及时间标记处理。通过一个具体实例,展示了如何在UVM组件中使用TLM2.0的initiator和target socket进行数据传输,并说明了标准数据包格式和精确时间标记的优势。最后指出TLM2.0在UVM中的实现主要是为了与Syste 阅读详情

相关推荐

用STM32H7的FMC+AD7606搭建多通道数据采集系统:两种工作模式(查询与FIFO中断)的代码详解与性能对比

本文详细解析了基于STM32H7微控制器和AD7606 ADC芯片的多通道数据采集系统设计,重点对比了查询模式与FIFO中断模式的实现方法与性能差异。通过FMC总线实现高速并行数据采集,系统支持16bit同步采样,最高可达200Ksps/通道。文章提供了完整的代码实现和优化策略,帮助工程师在工业监测等实时性要求高的场景中构建可靠的数据采集方案。

weixin_30599769的博客 488

ZOJ 3872 Beauty of Array (The 12th Zhejiang Provincial Collegiate Programming Contest )

【题目链接】click here~~ 【题目大意】定义Beauty数是一个序列里所有不相同的数的和,求一个序列所有字序列的Beauty和   1 N 【解题思路】由于数据比较大,常规方法求字序列和肯定是行不通的,我们不妨这样想:因为要区别于不同的数 ,可以看成序列里的数是一个一个加进去的,每次加入一个数,统计前面序列里第一次出现新加入的这个数的位置,表达的不好, 举个例子:

herongwei 的 BLOG 2535

具有I2S输出的多模数字麦克风ICS-43434咪头LR引脚接地或电源WS接LRCLK

ICS-43434 是一款数字 IS 输出底部收音孔麦克风。完整的 ICS-43434 解决方案包括 MEMS 传感器、信号调理、模数转换器、抽取和抗混叠滤波器、电源管理以及行业标准的 24 位 12S 接口。12S 接口允许 ICS-43434 直接连接到数字处理器,例如 DSP 和微控制器,而无需系统中的音频编解码器。

易板 5665

The 12th Zhejiang Provincial Collegiate Programming Contest -- 第七场选拔赛

I:Earthstone Keeper 题意: 给你一个n*m的迷宫,你要从起点走到终点,每个格子有怪兽和夹子和墙,墙不能走,夹子踩上去会受到伤害,但是踩完之后夹子会刷新好, 你走到怪兽旁边,怪兽会对你造成伤害,同样你会杀死怪兽,不会复活。要求路途 受到的伤害最小,伤害相同保证距离最小。 思路: 本以为是一个搜索,上了类似dijkstra,可能Node 结点里存的太多了 一直TLE. 应

aozil_yang的博客 518

ViViT视频分类实战:从Tubelet Embedding到4种Attention变体的保姆级解析

本文深入解析ViViT(Video Vision Transformer)在视频分类中的实战应用,重点介绍Tubelet Embedding技术和4种Attention变体的实现细节。通过对比分析Spatio-Temporal、Factorised Encoder等不同Attention机制的性能特点,提供工程优化策略和Kinetics数据集上的实战示例,帮助开发者掌握这一前沿视频理解技术。

weixin_29292535的博客 387

【Python&RS】Rasterio库安装+基础函数使用教程

Rasterio是一个Python库,专门用于栅格数据的读写操作。它支持多种栅格数据格式,如GeoTIFF、ENVI和HDF5,为处理和分析栅格数据提供了强大的工具。RasterIO适用于各种栅格数据应用,如卫星遥感、地图制作等。这篇文章跟大家介绍一下Rasterio库的安装以及一些基本函数的使用教程,附带源码。

Remote Sensing迷途小书童 1万+

140 - The 12th Zhejiang Provincial Collegiate Programming Contest(第二部分)

140 - The 12th Zhejiang Provincial Collegiate Prog,Floor Function, Permutation Graph, Lunch Time, May Day Holiday

寻找&星空の孩子 2008

【云原生进阶之容器】第六章容器网络6.6.2--Cilium部署

部署Cilium非常简单,可以通过单独的yaml文件部署全部组件(目前我使用了这个方式部署了1.7.1版本),也可以通过Helm Chart一键完成。重要的是部署环境和时机:官方建议所有部署节点都使用Linux最新稳定内核版本,这样所有的功能都能启用。作为一个Kubernetes网络组件,它应该在部署Kubernetes其他基础组件之后,才进行部署。

junbaozi的专栏 793

The 12th Zhejiang Provincial Collegiate Programming Contest - A

#include #include #include #include using namespace std; int a[1500],b[1500]; int c[1500]; int d[1500]; int main() { set st; int t; int n; scanf("%d",&t); while(t--) {

24小时的程序员 950

pg lib的信息及产生pg lib的三种方法

pg lib相比basic lib会多几方面pg 信息。除了pg arc(pg pin)以外,liberty还提供电压值,以及pmk cell的power_down_function功能相关信息。1.电压值除了常见的primary pg还有secondary pg和衬底。2.pg arc后端需要去做redhawk功耗分析,需要pg liberty提供pg arc,如果没有pg arc就需要手动去写custom lib代替3.pmk cell的power_down_function。

m0_61544122的博客 595

24、中性原子量子计算:原理、方法与实验

本文系统介绍了中性原子量子计算的原理、方法与实验进展。重点阐述了利用碱金属原子作为量子比特,通过磁光阱、光偶极阱和光晶格等技术实现原子捕获与控制的方法。同时,详细分析了单量子比特门操作和量子态工程的实现手段,并总结了相关实验结果与未来发展方向。该技术路线为构建大规模量子计算系统提供了可行方案。

ol789012的博客 246

The 12th Zhejiang Provincial Collegiate Programming Contest - J

#include #include #include #include #include using namespace std; int len; char str[400000]; int main () { int i,j; while (gets(str)!=NULL) { len = strlen(str); for

24小时的程序员 839

YOLOv13添加DRB模块map暴涨12.33!准确率提升8.56!召回率提升15.66

本文介绍了在YOLOv13模型中添加DRB模块的改进方法。实验结果显示,添加DRB模块后模型性能显著提升,mAP暴涨12.33%,准确率提升8.56%。文章详细说明了移植过程,包括创建yolov13-DRB.yaml配置文件、修改tasks.py和__init__.py文件,以及引入UniRepLKNet模块的具体实现。其中重点描述了GRNwithNHWC、NCHWtoNHWC等核心组件的实现细节,并提供了完整的模型结构配置代码。这些改进使得YOLOv13模型在保持原有架构优势的同时,获得了更强大的特征提取

FJN110的博客 2821

The 12th Zhejiang Provincial Collegiate Programming Contest(部分)

A     Ace of Aces Time Limit: 2 Seconds      Memory Limit: 65536 KB There is a mysterious organization called Time-Space Administrative Bureau (TSAB) in the deep universe that we humans have not

叶孤心的专栏 1730

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

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

The 12th Zhejiang Provincial Collegiate Programming Contest - L

#include #include using namespace std; int main() { int t; int n; scanf("%d",&t); while(t--) { scanf("%d",&n); int ans=0; for(int i=0;i<n;i++) {

24小时的程序员 882

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

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

ZOJ 3875 Lunch Time (The 12th Zhejiang Provincial Collegiate Programming Contest )

【题目链接】:click here~~ 【题目大意】给出一些点心的单价和数量,求出中位数单价的点心 【解题思路】排序一遍,取中位数就可以了 代码: #include using namespace std; struct node{ char ch[100]; int value; } dish[100000],a,b,c; int T; bool cmp(node a,n

herongwei 的 BLOG 1591

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

The 12th Zhejiang Provincial Collegiate Programming Contest - D

#include #include using namespace std; long long f[200005]; int vis[200005]; int main() { int t; int n; scanf("%d",&t); while(t--) { scanf("%d",&n); f[0]=0;

24小时的程序员 1027

ZOJ 3876 May Day Holiday (The 12th Zhejiang Provincial Collegiate Programming Contest)

【题目链接】click here~~ 【题目大意】求一个年份的五月一号可以连续放几天假 【解题思路】类似与求某年某月某日是星期几的问题,有好多解法,在这里笔者用了基姆拉尔森计算公式 解法如下: 基姆拉尔森计算公式 week=(data+ 2*month + 3*(month+1)/5+year+year/4 -year/100 + year/400) % 7; 在公式中data表示日期

herongwei 的 BLOG 1372

The 12th Zhejiang Provincial Collegiate Programming Contest - G

#include #include #include using namespace std; struct node { int x; char c[1000]; }; int cmp(const node a,const node b) { return a.x<b.x; } node aa[200],bb[200],cc[200]; int main() {

24小时的程序员 584

Ace of Aces【The 12th Zhejiang Provincial Collegiate Programming Contest】

Click to view the problem题意:TSAB 这个玩意要举行投票,选出Ace of Aces,如果有两个或两个以上的最多票数,就输出nobody,不然就输出获得最多票数的编号。 思路:将每个编号获得的票数计算出来,比较是否有两个或两个以上的最大值。#include <iostream> #include <cstdio> #include <algorithm> #includ

工厂搬砖的代码小白 542

May Day Holiday【The 12th Zhejiang Provincial Collegiate Programming Contest】

Click to view the problem题意: Marjar University 放五一假期,照常的话五一会放五天的假。但会和周末撞在一起。比如5.1是星期一,就会从4.29一直放假到5.7 总共9天。现在给你一个年份,求出这一年五一会放几天假。 思路:主要问题就是确定某一年的五月一号是星期几。所以就需要用到一个公式:s=y-1+(y-1)/4-(y-1)/100+(y-1)/400+

工厂搬砖的代码小白 501

ZOJ 3869 Ace of Aces (The 12th Zhejiang Provincial Collegiate Programming Contest)

【题目链接】click here~~ 【题目大意】每张票有不同的投票数,如果有两张或以上的相同则无法选拔“Ace of Aces”,给出票的数目,判断是否符合 【解题思路】:签到题 代码: #include using namespace std; int a[1001]; int main() { // freopen("in.txt","r",stdin); int

herongwei 的 BLOG 1693

The 12th Zhejiang Provincial Collegiate Programming Contest - H

#include #include using namespace std; int w[10000]; int rr(int y) { if((y%4==0&&y%100!=0)||(y%400==0)) return 1; else return 0; } int getd(int y) { if(rr(y)) re

24小时的程序员 615

Lunch Time【The 12th Zhejiang Provincial Collegiate Programming Contest】

Click to view the problem题意:一个人吃饭,种类有三类,每类来一份。每类要选则价格在中间的那一种食物,如果每类有n中,n为偶数,那么就选择中间值较贵的那一份。 思路:将每种价格排序,求出价格,寻出食物名称。#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #includ

工厂搬砖的代码小白 497

zoj The 12th Zhejiang Provincial Collegiate Programming Contest Team Formation

http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5494 The 12th Zhejiang Provincial Collegiate Programming Contest - B Team FormationTime Limit:3 Seconds Memory Limit:131...

weixin_30256901的博客 170

zoj The 12th Zhejiang Provincial Collegiate Programming Contest Lunch Time

http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5499 The 12th Zhejiang Provincial Collegiate Programming Contest - G Lunch TimeTime Limit:2 Seconds Memory Limit:6553...

weixin_30487201的博客 162
上一篇: 拓扑排序
下一篇: The 4th Zhejiang Provincial Collegiate Programming Contest
Linnnnnger
博客等级 码龄11年 71粉丝 79原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值