自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(188)
  • 资源 (1)
  • 收藏
  • 关注

原创 Transformer模型详解

Transformer模型详解参考自台大李宏毅老师课件Transformer模型是谷歌大脑在2017年底发表的论文Attention Is All You Need[1]中所提出seq2seq模型。而Transformer这个seq2seq模型的特别之处是模型当中大量用到了Self-Attention这种特别的Layer。因此首先我们需要来了解的是Self-Attention这种特别的Layer。1 Self-Attention1.1 RNN如果我们谈到处理一个Sequence,我们最常想到拿来用

2021-03-30 22:05:49 19085 4

原创 POJ1265 Area【数学几何】

DescriptionBeing well known for its highly innovative products, Merck would definitely be a good target for industrial espionage. To protect its brand-new research and development facility the company has installed the latest system of surveillance robot

2020-06-29 17:03:51 299

原创 POJ3020 Antenna Placement【二分图匹配问题——最小边覆盖】

DescriptionThe Global Aerial Research Centre has been allotted the task of building the fifth generation of mobile phone nets in Sweden. The most striking reason why they got the job, is their discovery of a new, highly noise resistant, antenna. It is ca

2020-06-29 10:30:08 298

原创 POJ3041 Asteroids【最小顶点覆盖问题】

DescriptionBessie wants to navigate her spaceship through a dangerous asteroid field in the shape of an N x N grid (1 <= N <= 500). The grid contains K asteroids (1 <= K <= 10,000), which are conveniently located at the lattice points of the

2020-06-28 16:41:15 562

原创 POJ3687 Labeling Balls【优先队列+反向拓扑排序】

DescriptionWindy hasNballs of distinct weights from 1 unit toNunits. Now he tries to label them with 1 toNin such a way that:No two balls share the same label. The labeling satisfies several constrains like "The ball labeled withais lighter th...

2020-06-27 15:35:41 165

原创 POJ1094 Sorting It All Out【拓扑排序】

DescriptionAn ascending sorted sequence of distinct values is one in which some form of a less-than operator is used to order the elements from smallest to largest. For example, the sorted sequence A, B, C, D implies that A < B, B < C and C < D.

2020-06-27 11:30:54 155

原创 POJ3026 Borg Maze【BFS+最小生成树】

DescriptionThe Borg is an immensely powerful race of enhanced humanoids from the delta quadrant of the galaxy. The Borg collective is the term used to describe the group consciousness of the Borg civilization. Each Borg individual is linked to the collec

2020-06-25 16:17:55 318

原创 POJ1258 Agri-Net【最小生成树】

DescriptionFarmer John has been elected mayor of his town! One of his campaign promises was to bring internet connectivity to all farms in the area. He needs your help, of course.Farmer John ordered a high speed connection for his farm and is going to s

2020-06-25 11:01:24 137

原创 POJ2458 Highways【最小生成树、Prim】

DescriptionThe island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has no public highways. So the traffic is difficult in Flatopia. The Flatopian government is aware of this problem. They're planning to build some highways so that it wil

2020-06-25 09:32:22 224

原创 POJ1789 Truck History【最小生成树、普里姆】

DescriptionAdvanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are used for vegetable delivery, other for furniture, or for bricks. The company has its own code describing each type of a truck. The code is simply a string of exactly

2020-06-21 19:21:06 211

原创 POJ2240 Arbitrage【Bellman_Ford】

DescriptionArbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currency. For example, suppose that 1 US Dollar buys 0.5 British pound, 1 British pound buys 10.0 French .

2020-06-21 10:35:10 197

原创 POJ1125 Stockbroker Grapevine【Floyd】

DescriptionStockbrokers are known to overreact to rumours. You have been contracted to develop a method of spreading disinformation amongst the stockbrokers to give your employer the tactical edge in the stock market. For maximum effect, you have to spre

2020-06-20 17:04:14 168

原创 POJ2253 Frogger【minimax distance、Floyd、Dijkstra】

DescriptionFreddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sitting on another stone. He plans to visit her, but since the water is dirty and full of tourists' sunscreen, he wants to avoid swimming and inst

2020-06-20 16:16:14 153

原创 POJ1062 昂贵的聘礼【Dijkstra】

Description年轻的探险家来到了一个印第安部落里。在那里他和酋长的女儿相爱了,于是便向酋长去求亲。酋长要他用10000个金币作为聘礼才答应把女儿嫁给他。探险家拿不出这么多金币,便请求酋长降低要求。酋长说:"嗯,如果你能够替我弄到大祭司的皮袄,我可以只要8000金币。如果你能够弄来他的水晶球,那么只要5000金币就行了。"探险家就跑到大祭司那里,向他要求皮袄或水晶球,大祭司要他用金币来换,或者替他弄来其他的东西,他可以降低价格。探险家于是又跑到其他地方,其他人也提出了类似的要求,或者直接用金币换,

2020-06-20 13:45:31 171

原创 POJ3259 Wormholes【SPFA】

DescriptionWhile exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is very peculiar because it is a one-way path that delivers you to its destination at a time that is BEFORE you entered the wormhole! Each of

2020-06-19 22:55:13 148

原创 POJ1860 Currency Exchange【Bellman_Ford】

DescriptionSeveral currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations only with these currencies. There can be several points specializing in the same

2020-06-19 10:52:42 174

原创 POJ3083 Children of the Candy Corn【DFS、BFS】

DescriptionThe cornfield maze is a popular Halloween treat. Visitors are shown the entrance and must wander through the maze facing zombies, chainsaw-wielding psychopaths, hippies, and other terrors on their quest to find the exit.One popular maze-walk.

2020-06-18 21:02:36 148

原创 POJ3278 Catch That Cow【BFS】

DescriptionFarmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a pointN(0 ≤N≤ 100,000) on a number line and the cow is at a pointK(0 ≤K≤ 100,000) on the same number line. Farmer John h...

2020-06-18 15:34:42 125

原创 POJ2386 Lake Counting【DFS、BFS】

DescriptionDue to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 <= N <= 100; 1 <= M <= 100) squares. Each square contains either water ('W') or dry land ('.'). Farmer

2020-06-18 11:04:30 135

原创 POJ3126 Prime Path【BFS、埃氏筛】

DescriptionThe ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room numbers on their offices.— It is a matter of security to change such things every now and t

2020-06-18 10:37:28 191

原创 POJ3669 Meteor Shower【BFS】

DescriptionBessie hears that an extraordinary meteor shower is coming; reports say that these meteors will crash into earth and destroy anything they hit. Anxious for her safety, she vows to find her way to a safe location (one that is never destroyed by

2020-06-17 15:57:48 173

原创 POJ1248 Safecracker【DFS】

Description"The item is locked in a Klein safe behind a painting in the second-floor library. Klein safes are extremely rare; most of them, along with Klein and his factory, were destroyed in World War II. Fortunately old Brumbaugh from research knew Kle

2020-06-17 10:14:46 147

原创 P1449 后缀表达式【STL栈、后缀表达式】

题目描述所谓后缀表达式是指这样的一个表达式:式中不再引用括号,运算符号放在两个运算对象之后,所有计算按运算符号出现的顺序,严格地由左而右新进行(不用考虑运算符的优先级)。如:3*(5–2)+7对应的后缀表达式为:3.5.2.-*7.+@。’@’为表达式的结束符号。‘.’为操作数的结束符号。输入格式输入:后缀表达式输出格式输出:表达式的值输入输出样例输入3.5.2.-*7.+@输出16说明/提示字符串长度,1000内。解题思路计算后缀表达式需..

2020-06-16 17:04:24 446

原创 P1259 黑白棋子的移动【递归】

题目描述有2n个棋子(n≥4)排成一行,开始为位置白子全部在左边,黑子全部在右边,如下图为n=5的情况:○○○○○●●●●●移动棋子的规则是:每次必须同时移动相邻的两个棋子,颜色不限,可以左移也可以右移到空位上去,但不能调换两个棋子的左右位置。每次移动必须跳过若干个棋子(不能平移),要求最后能移成黑白相间的一行棋子。如n=5时,成为:○●○●○●○●○●任务:编程打印出移动过程。输入格式一个整数n(n<=100)输出格式若干行,表示初始状态和每次移动的状态,用"o"

2020-06-16 16:18:29 2047

原创 P3612 [USACO17JAN]Secret Cow Code S【递推】

题目描述The cows are experimenting with secret codes, and have devised a method for creating an infinite-length string to be used as part of one of their codes.Given a stringss, letF(s)F(s)bessfollowed byss"rotated" one character to the right (in a ...

2020-06-16 15:25:01 454

原创 P1928 外星密码【递归】

题目描述有了防护伞,并不能完全避免 2012 的灾难。地球防卫小队决定去求助外星种族的帮 助。经过很长时间的努力,小队终于收到了外星生命的回信。但是外星人发过来的却是一 串密码。只有解开密码,才能知道外星人给的准确回复。解开密码的第一道工序就是解压 缩密码,外星人对于连续的若干个相同的子串“X”会压缩为“[DX]”的形式(D 是一个整 数且 1≤D≤99),比如说字符串“CBCBCBCB”就压缩为“[4CB]”或者“[2[2CB]]”,类 似于后面这种压缩之后再压缩的称为二重压缩。如果是“[2[2[2.

2020-06-16 12:30:33 973 8

原创 P1255 数楼梯【斐波那契数列、高精度】

题目描述楼梯有N阶,上楼可以一步上一阶,也可以一步上二阶。编一个程序,计算共有多少种不同的走法。输入格式一个数字,楼梯数。输出格式走的方式几种。输入输出样例输入4输出5说明/提示60% N<=50100% N<=5000)解题思路这道题目自己先手动算出前几个答案,会发现是一个斐波那契数列。不过简单分析也可得知这是一个斐波那契数列(其中Fibo[n]表示第n阶楼梯的走法总数):对于第n阶楼梯可以有两种状态得来:先走n-1阶.

2020-06-16 10:56:31 627

原创 P2392 kkksc03考前临时抱佛脚【dp、01背包】

题目背景kkksc03 的大学生活非常的颓废,平时根本不学习。但是,临近期末考试,他必须要开始抱佛脚,以求不挂科。题目描述这次期末考试,kkksc03 需要考4科。因此要开始刷习题集,每科都有一个习题集,分别有 s1​,s2​,s3​,s4​道题目,完成每道题目需要一些时间,可能不等(A1​,A2​,…,As1​​,B1​,B2​,…,Bs2​​,C1​,C2​,…,Cs3​​,D1​,D2​,…,Ds4​​)。kkksc03 有一个能力,他的左右两个大脑可以同时计算2道不同的题目...

2020-06-16 10:23:27 308

原创 P3799 妖梦拼木棒【暴力枚举、组合数】

题目背景上道题中,妖梦斩了一地的木棒,现在她想要将木棒拼起来。题目描述有nn根木棒,现在从中选44根,想要组成一个正三角形,问有几种选法?答案对10^9+7109+7取模。输入格式第一行一个整数nn。第二行nn个整数,第ii个整数a_iai​代表第ii根木棒的长度。输出格式一行一个整数代表答案。输入输出样例输入4 1 1 2 2输出1说明/提示数据规模与约定对于30\%30%的数据,保证n \le ...

2020-06-15 10:34:12 422

原创 P1149 火柴棒等式【暴力枚举】

题目描述给你n根火柴棍,你可以拼出多少个形如“A+B=C”的等式?等式中的A、B、C是用火柴棍拼出的整数(若该数非零,则最高位不能是0)。用火柴棍拼数字0-9的拼法如图所示:注意: 加号与等号各自需要两根火柴棍 如果A≠B,则A+B=C与B+A=C视为不同的等式(A,B,C>=0) n根火柴棍必须全部用上 输入格式一个整数n(n<=24)。输出格式一个整数,能拼成的不同等式的数目。输入输出样例输入14输出2...

2020-06-14 18:59:24 353

原创 P1217 [USACO1.5]回文质数 Prime Palindromes【暴力枚举、欧拉筛】

题目描述因为 151 既是一个质数又是一个回文数(从左到右和从右到左是看一样的),所以 151 是回文质数。写一个程序来找出范围[a,b] (5 \le a < b \le 100,000,000)[a,b](5≤a<b≤100,000,000)( 一亿)间的所有回文质数。输入格式第 1 行: 二个整数 a 和 b .输出格式输出一个回文质数的列表,一行一个。输入输出样例输入 #1复制5 500输出 #1复制5711101131151.

2020-06-14 16:13:56 206

原创 P3654 First Step (ファーストステップ)【暴力枚举】

题目背景知らないことばかりなにもかもが(どうしたらいいの?)一切的一切 尽是充满了未知数(该如何是好)それでも期待で足が軽いよ(ジャンプだ!)但我仍因满怀期待而步伐轻盈(起跳吧!)温度差なんていつか消しちゃえってね冷若冰霜的态度 有朝一日将会消失得无影无踪元気だよ元気をだしていくよ拿出活力 打起精神向前迈进吧我们Aqours,要第一次举办演唱会啦!虽然学生会长看上去不怎么支持我们的样子,可是有了理事长的支持,我们还是被允许在校内的篮球场里歌唱!歌曲也好好地准备

2020-06-14 12:13:51 663

原创 P3392 涂国旗【暴力枚举】

题目描述某国法律规定,只要一个由N×M个小方块组成的旗帜符合如下规则,就是合法的国旗。(毛熊:阿嚏——)从最上方若干行(至少一行)的格子全部是白色的; 接下来若干行(至少一行)的格子全部是蓝色的; 剩下的行(至少一行)全部是红色的;现有一个棋盘状的布,分成了N行M 列的格子,每个格子是白色蓝色红色之一,小 a 希望把这个布改成该国国旗,方法是在一些格子上涂颜料,盖住之前的颜色。小a很懒,希望涂最少的格子,使这块布成为一个合法的国旗。输入格式第一行是两个整数 N,M。接下...

2020-06-14 10:52:45 1780

原创 P1088 火星人【暴力枚举、全排列】

题目描述人类终于登上了火星的土地并且见到了神秘的火星人。人类和火星人都无法理解对方的语言,但是我们的科学家发明了一种用数字交流的方法。这种交流方法是这样的,首先,火星人把一个非常大的数字告诉人类科学家,科学家破解这个数字的含义后,再把一个很小的数字加到这个大数上面,把结果告诉火星人,作为人类的回答。火星人用一种非常简单的方式来表示数字――掰手指。火星人只有一只手,但这只手上有成千上万的手指,这些手指排成一列,分别编号为1,2,3…。火星人的任意两根手指都能随意交换位置,他们就是通过这方法计数的。

2020-06-13 15:42:08 255

原创 P1706 全排列问题【dfs+回溯、c++中全排列函数使用】

题目描述输出自然数1到n所有不重复的排列,即n的全排列,要求所产生的任一数字序列中不允许出现重复的数字。输入格式一个整数n。输出格式由1∼n组成的所有不重复的数字序列,每行一个序列。每个数字保留5个场宽。输入输出样例输入3输出 1 2 3 1 3 2 2 1 3 2 3 1 3 1 2 3 2 1说明/提示1≤n...

2020-06-13 11:04:10 284

原创 C++ 中 next_permutation全排列函数的用法

参考博客:next_permutation(a,a+n)问题考虑三个字符所组成的序列{a,b,c}。这个序列有六个可能的排列组合:abc,acb,bac,bca,cab,cba。而在这里我们是按照字典排序的。对于这种排列组合问题我们一般常采用的是暴力枚举的方法,即dfs+回溯。但是殊不知,其实在头文件algorithm.h中给我们提供了一个非常强大且好用的全排列函数:next_permutation()全排列函数的使用这里介绍两个计算序列全排列的函数:next_permutati

2020-06-13 10:57:48 465

原创 P1157 组合的输出【暴力枚举、dfs】

题目描述排列与组合是常用的数学方法,其中组合就是从nn个元素中抽出rr个元素(不分顺序且r \le n)r≤n),我们可以简单地将nn个元素理解为自然数1,2,…,n1,2,…,n,从中任取rr个数。现要求你输出所有组合。例如n=5,r=3n=5,r=3,所有组合为:12 3 , 1 2 4 , 1 2 5 , 1 3 4 ,1 3 5 , 1 4 5 , 2 3 4 , 2 3 5 , 2 4 5 , 3 4 5123,124,125,134,135,145,234,235,245,345

2020-06-13 09:40:11 647

原创 P1036 选数【暴力枚举、dfs】

题目描述已知nn个整数x_1,x_2,…,x_nx1​,x2​,…,xn​,以及11个整数kk(k<nk<n)。从nn个整数中任选kk个整数相加,可分别得到一系列的和。例如当n=4,k=3n=4,k=3,44个整数分别为3,7,12,193,7,12,19时,可得全部的组合与它们的和为:3+7+12=223+7+12=223+7+19=293+7+19=297+12+19=387+12+19=383+12+19=343+12+19=34。现在,要求你计算出和为素数共...

2020-06-13 09:06:24 215

原创 P1618 三连击(升级版)【暴力枚举】

题目描述将1, 2,\ldots, 91,2,…,9共99个数分成三组,分别组成三个三位数,且使这三个三位数的比例是A:B:CA:B:C,试求出所有满足条件的三个三位数,若无解,输出No!!!。//感谢黄小U饮品完善题意输入格式三个数,A,B,CA,B,C。输出格式若干行,每行33个数字。按照每行第一个数字升序排列。输入输出样例输入1 2 3输出192 384 576219 438 657273 546 819327 654 981说...

2020-06-12 20:12:32 605

原创 P2089 烤鸡【暴力枚举、dfs】

题目背景猪猪 Hanke 得到了一只鸡。题目描述猪猪 Hanke 特别喜欢吃烤鸡(本是同畜牲,相煎何太急!)Hanke 吃鸡很特别,为什么特别呢?因为他有1010种配料(芥末、孜然等),每种配料可以放11到33克,任意烤鸡的美味程度为所有配料质量之和。现在, Hanke 想要知道,如果给你一个美味程度nn,请输出这1010种配料的所有搭配方案。输入格式一个正整数nn,表示美味程度。输出格式第一行,方案总数。第二行至结束,1010个数,表示每种配料所...

2020-06-12 18:11:32 288

数据结构课的代码.rar

数据结构课中的课程代码总结

2019-06-01

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除