YunYan

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

07 2019 档案

摘要:Suppose there are 5 types of coins: 50-cent, 25-cent, 10-cent, 5-cent, and 1-cent. We want to makechanges with these coins for a given amount of money 阅读全文
posted @ 2019-07-31 22:48 Target--fly 阅读(198) 评论(0) 推荐(0)

摘要:解决背包问题的第一步就是先找到背包的容积还有物品价值和单个体积。。 01背包: 状态转移方程:dp[i + 1][j ] =max(dp[i ][j ]; dp[i ][j 􀀀 w[i ]] + v[i ]) 其他 =dp[i ][j ] (j < w[i ]) 核心代码: int dp[ MAX 阅读全文
posted @ 2019-07-31 21:33 Target--fly 阅读(864) 评论(0) 推荐(0)

摘要:可怜的POIUYTREWQ最近想买下dota2的商品,但是手头缺钱。他想起了之前看过的一部大片,觉得抢银行也许是个不错的选择。他认为,坏人被抓是因为没有预先规划。于是他在之前的几个月对各大银行进行了一次评估; 评估内容包括安全性和可盗窃金额: 他想知道在在某个风险系数下可以偷窃的最大金额 Input 阅读全文
posted @ 2019-07-31 21:08 Target--fly 阅读(314) 评论(0) 推荐(0)

摘要:在 ACM 能够开展之前,必须准备预算,并获得必要的财力支持。该活动的主要收入来自于 Irreversibly Bound Money (IBM)。思路很简单。任何时候,某位 ACM 会员有少量的钱时,他将所有的硬币投入到小猪储钱罐中。这个过程不可逆,因为只有把小猪储钱罐打碎才能取出硬币。在足够长的 阅读全文
posted @ 2019-07-31 18:47 Target--fly 阅读(822) 评论(0) 推荐(0)

摘要:You have a long drive by car ahead. You have a tape recorder, but unfortunately your best music is on CDs. You need to have it on tapes so the problem 阅读全文
posted @ 2019-07-31 15:57 Target--fly 阅读(507) 评论(0) 推荐(0)

摘要:用bfs遍历最图求最短路径时通常借用优先队列即优先考虑最大的或者最小的权值 方法1 优先队列:(内置函数,优先考虑较小的权值) 方法2:队列加判断条件(开一个数组step,加一个判断条件step [ d x ] [ d y ] > step [x] [y] + mp [dx] [dy] ) 阅读全文
posted @ 2019-07-30 22:40 Target--fly 阅读(1239) 评论(0) 推荐(0)

摘要:LL最近沉迷于AC不能自拔,每天寝室、机房两点一线。由于长时间坐在电脑边,缺乏运动。他决定充分利用每次从寝室到机房的时间,在校园里散散步。整个HDU校园呈方形布局,可划分为n*n个小方格,代表各个区域。例如LL居住的18号宿舍位于校园的西北角,即方格(1,1)代表的地方,而机房所在的第三实验楼处于东 阅读全文
posted @ 2019-07-30 20:43 Target--fly 阅读(134) 评论(0) 推荐(0)

摘要:The king has guards of all different heights. Rather than line them up in increasing or decreasing height order, he wants to line them up so each guar 阅读全文
posted @ 2019-07-30 19:29 Target--fly 阅读(157) 评论(0) 推荐(0)

摘要:Given three strings, you are to determine whether the third string can be formed by combining the characters in the first two strings. The first two s 阅读全文
posted @ 2019-07-30 16:41 Target--fly 阅读(151) 评论(0) 推荐(0)

摘要:1.记忆化搜索的思想 记忆化搜索的思想是,在搜索过程中,会有很多重复计算,如果我们能记录一些状态的答案,就可以减少重复搜索量 2、记忆化搜索的适用范围 根据记忆化搜索的思想,它是解决重复计算,而不是重复生成,也就是说,这些搜索必须是在搜索扩展路径的过程中分步计算的题目,也就是“搜索答案与路径相关”的 阅读全文
posted @ 2019-07-30 13:48 Target--fly 阅读(284) 评论(0) 推荐(0)

摘要:1.斐波那契:gcd(f(n),f(m))==f(__gcd(n,m)) 2.同余定理: 只对“+”、“×”成立,对“-”、“/”不成立 (a+b)%m = (a%m+b%m)%m; a*b%m = ((a%m)*(b%m))%m; 3.斐波那契数列的奇偶性: 1 2 3 4 5 6 7 8 9 1 阅读全文
posted @ 2019-07-29 23:35 Target--fly 阅读(144) 评论(0) 推荐(0)

摘要:链接:https://ac.nowcoder.com/acm/contest/948/F来源:牛客网 输入2个正整数x0,y0(2<=x0<100000,2<=y0<=1000000),求出满足下列条件的P,Q的个数。 条件: 1. P,Q是正整数; 2. 要求P,Q以x0为最大公约数,以y0为最小 阅读全文
posted @ 2019-07-28 21:53 Target--fly 阅读(241) 评论(0) 推荐(0)

摘要:有两个只由小写字母组成的长度为n的字符串s1,s2和m组字母对应关系,每一组关系由两个字母c1和c2组成,代表c1可以直接变成c2,你需要判断s1是否可以通过这m组关系转换为s2。 有两个只由小写字母组成的长度为n的字符串s1,s2和m组字母对应关系,每一组关系由两个字母c1和c2组成,代表c1可以 阅读全文
posted @ 2019-07-28 14:31 Target--fly 阅读(115) 评论(0) 推荐(0)

摘要:D. Points in rectangle 单点时限: 2.0 sec 内存限制: 512 MB 单点时限: 2.0 sec 内存限制: 512 MB 单点时限: 2.0 sec 内存限制: 512 MB 在二维平面中有一个矩形,它的四个坐标点分别为(0,a),(a,0),(n,n−a),(n−a 阅读全文
posted @ 2019-07-28 13:44 Target--fly 阅读(138) 评论(0) 推荐(0)

摘要:B. 恐怖的怪物 单点时限: 5.0 sec 内存限制: 512 MB 单点时限: 5.0 sec 内存限制: 512 MB 单点时限: 5.0 sec 内存限制: 512 MB 一天早上,Dicer一觉醒来,发现自己来到了MineCraft的世界里面,身为MineCraft游戏爱好者的他欣喜不已, 阅读全文
posted @ 2019-07-28 13:42 Target--fly 阅读(249) 评论(0) 推荐(0)

摘要:A. 再战斐波那契 单点时限: 1.0 sec 内存限制: 512 MB 单点时限: 1.0 sec 内存限制: 512 MB 单点时限: 1.0 sec 内存限制: 512 MB 小z 学会了斐波那契和 gcd 后,老师又给他出了个难题,求第N个和第M个斐波那契数的最大公约数,这可难倒了小z ,不 阅读全文
posted @ 2019-07-28 13:34 Target--fly 阅读(123) 评论(0) 推荐(0)

摘要:给定一个m × n (m行, n列)的迷宫,迷宫中有两个位置,gloria想从迷宫的一个位置走到另外一个位置,当然迷宫中有些地方是空地,gloria可以穿越,有些地方是障碍,她必须绕行,从迷宫的一个位置,只能走到与它相邻的4个位置中,当然在行走过程中,gloria不能走到迷宫外面去。令人头痛的是,g 阅读全文
posted @ 2019-07-26 23:45 Target--fly 阅读(223) 评论(0) 推荐(0)

摘要:计院有一个bug电梯,可能是hyk造的,很多bug,电梯只有两个按钮,“上”和“下”,电梯每层都可以停,每层都有一个数字Ki(0<=Ki<=n),当你在一层楼,你按“上”键会到1+K1层,你按“下”键会到1-K1层。当然,电梯不能升到N以上,也不能降到1以下。例如,有一个五层楼的建筑,k1=3,k2 阅读全文
posted @ 2019-07-26 17:22 Target--fly 阅读(138) 评论(0) 推荐(0)

摘要:Ignatius被魔王抓走了,有一天魔王出差去了,这可是Ignatius逃亡的好机会. 魔王住在一个城堡里,城堡是一个A*B*C的立方体,可以被表示成A个B*C的矩阵,刚开始Ignatius被关在(0,0,0)的位置,离开城堡的门在(A-1,B-1,C-1)的位置,现在知道魔王将在T分钟后回到城堡, 阅读全文
posted @ 2019-07-26 17:19 Target--fly 阅读(165) 评论(0) 推荐(0)

摘要:Ignatius had a nightmare last night. He found himself in a labyrinth with a time bomb on him. The labyrinth has an exit, Ignatius should get out of th 阅读全文
posted @ 2019-07-26 17:18 Target--fly 阅读(119) 评论(0) 推荐(0)

摘要:可怜的公主在一次次被魔王掳走一次次被骑士们救回来之后,而今,不幸的她再一次面临生命的考验。魔王已经发出消息说将在T时刻吃掉公主,因为他听信谣言说吃公主的肉也能长生不老。年迈的国王正是心急如焚,告招天下勇士来拯救公主。不过公主早已习以为常,她深信智勇的骑士LJ肯定能将她救出。 现据密探所报,公主被关在 阅读全文
posted @ 2019-07-26 17:10 Target--fly 阅读(163) 评论(0) 推荐(0)

摘要:一天早上小明醒来时发现他的宠物仓鼠不见了。 他在房间寻找但是没找到仓鼠。 他想用奶酪诱饵去找回仓鼠。 他把奶酪诱饵放在房间并且等待了好几天。 但是可怜的小明除了老鼠和蟑螂没见到任何东西。 他找到学校的地图发现地图上没有环路,并且学校里的每个站点都可以从他的房间到达。 奶酪诱饵的手册提到在距离D之内宠 阅读全文
posted @ 2019-07-26 17:07 Target--fly 阅读(199) 评论(0) 推荐(0)

摘要:呃......变形课上Harry碰到了一点小麻烦,因为他并不像Hermione那样能够记住所有的咒语而随意的将一个棒球变成刺猬什么的,但是他发现了变形咒语的一个统一规律:如果咒语是以a开头b结尾的一个单词,那么它的作用就恰好是使A物体变成B物体. Harry已经将他所会的所有咒语都列成了一个表,他想 阅读全文
posted @ 2019-07-26 16:58 Target--fly 阅读(227) 评论(0) 推荐(0)

摘要:You task is to find minimal natural number N, so that N! contains exactly Q zeroes on the trail in decimal notation. As you know N! = 1*2*...*N. For e 阅读全文
posted @ 2019-07-25 23:32 Target--fly 阅读(125) 评论(0) 推荐(0)

摘要:一所学校不久前买了第一台电脑(所以这台电脑的ID是1)。近年来,学校购买了N-1新电脑。每台新电脑都连接到一台先前安装的电脑上。学校的管理人员担心网络运行缓慢,希望知道第i台计算机需要发送信号的最大距离si(即到最远计算机的电缆长度)。您需要提供此信息。 提示:示例输入与此图对应。从图中,你可以看到 阅读全文
posted @ 2019-07-25 21:22 Target--fly 阅读(221) 评论(0) 推荐(0)

摘要:My birthday is coming up and traditionally I'm serving pie. Not just one pie, no, I have a number N of them, of various tastes and of various sizes. F 阅读全文
posted @ 2019-07-25 18:51 Target--fly 阅读(153) 评论(0) 推荐(0)

摘要:1.binary_search(arr[],arr[]+size,index) #include<algorithm> 功能 在数组中查找某个元素是否存在 函数模板:binary_search(地址1,地址2,v) 返回值:若是查到了v返回1,查找不到则返回0; 时间复杂度:log2(N)+2 2. 阅读全文
posted @ 2019-07-25 17:17 Target--fly 阅读(728) 评论(0) 推荐(0)

摘要:Give you three sequences of numbers A, B, C, then we give you a number X. Now you need to calculate if you can find the three numbers Ai, Bj, Ck, whic 阅读全文
posted @ 2019-07-25 16:46 Target--fly 阅读(209) 评论(0) 推荐(0)

摘要:思路:两次二分查找。。第一次寻找该数字第一次出现的位置,第二次查找该数字最后一次出现的位置 做差并加1; 阅读全文
posted @ 2019-07-25 15:17 Target--fly 阅读(1699) 评论(0) 推荐(0)

摘要:Given a tree (a connected graph with no cycles), you have to find the farthest nodes in the tree. The edges of the tree are weighted and undirected. T 阅读全文
posted @ 2019-07-25 13:22 Target--fly 阅读(168) 评论(0) 推荐(0)

摘要:Building and maintaining roads among communities in the far North is an expensive business. With this in mind, the roads are build such that there is 阅读全文
posted @ 2019-07-25 13:19 Target--fly 阅读(259) 评论(0) 推荐(0)

摘要:After hearing about the epidemic of obesity in the USA, Farmer John wants his cows to get more exercise, so he has committed to create a bovine marath 阅读全文
posted @ 2019-07-25 13:15 Target--fly 阅读(127) 评论(0) 推荐(0)

摘要:The northern part of the Pyramid contains a very large and complicated labyrinth. The labyrinth is divided into square blocks, each of them either fil 阅读全文
posted @ 2019-07-25 13:04 Target--fly 阅读(137) 评论(0) 推荐(0)

摘要:Now give you an string which only contains 0, 1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9.You are asked to add the sign ‘+’ or ’-’ between the characters. Just like giv 阅读全文
posted @ 2019-07-25 09:07 Target--fly 阅读(159) 评论(0) 推荐(0)

摘要:小明做了一个很久很久的梦,醒来后他竟发现自己和朋友在一个摇摇欲坠的大棋盘上,他们必须得想尽一切办法逃离这里。经过长时间的打探,小明发现,自己所在的棋盘格子上有个机关,上面写着“你只有一次机会,出发后t秒大门会为你敞开”,而他自己所在的棋盘是大小为 N*M 的长方形,他可以向上下左右四个方向移动(不可 阅读全文
posted @ 2019-07-25 08:37 Target--fly 阅读(163) 评论(0) 推荐(0)

摘要:Fox Ciel is playing a mobile puzzle game called "Two Dots". The basic levels are played on a board of size n × m cells, like this: Each cell contains 阅读全文
posted @ 2019-07-25 08:15 Target--fly 阅读(182) 评论(0) 推荐(0)

摘要:There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he c 阅读全文
posted @ 2019-07-24 23:43 Target--fly 阅读(141) 评论(0) 推荐(0)

摘要:[NWUACM] 你被困在一个三维的空间中,现在要寻找最短路径逃生!空间由立方体单位构成你每次向上下前后左右移动一个单位需要一分钟你不能对角线移动并且四周封闭是否存在逃出生天的可能性?如果存在,则需要多少时间? Input - 输入 输入第一行是一个数表示空间的数量。 每个空间的描述的第一行为L,R 阅读全文
posted @ 2019-07-24 23:39 Target--fly 阅读(185) 评论(0) 推荐(0)

摘要:A friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the shortest closed tour of knight moves that visits eac 阅读全文
posted @ 2019-07-24 23:34 Target--fly 阅读(211) 评论(0) 推荐(0)

摘要:A robot has been programmed to follow the instructions in its path. Instructions for the next direction the robot is to move are laid down in a grid. 阅读全文
posted @ 2019-07-24 17:52 Target--fly 阅读(302) 评论(0) 推荐(0)

摘要:在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。 Input 输入含有多组测试数据。 每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将 阅读全文
posted @ 2019-07-24 14:05 Target--fly 阅读(123) 评论(0) 推荐(0)

摘要:在N*N的方格棋盘放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在与棋盘边框成45角的斜线上。 你的任务是,对于给定的N,求出有多少种合法的放置方法。 Input共有若干行,每行一个正整数N≤10,表示棋盘和皇后的数量;如果N=0,表示结束。Output共有若 阅读全文
posted @ 2019-07-24 14:03 Target--fly 阅读(153) 评论(0) 推荐(0)

摘要:The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of 阅读全文
posted @ 2019-07-24 13:56 Target--fly 阅读(111) 评论(0) 推荐(0)

摘要:In this problem, you are given an integer number s. You can transform any integer number A to another integer number B by adding x to A. This x is an 阅读全文
posted @ 2019-07-23 23:29 Target--fly 阅读(141) 评论(0) 推荐(0)

摘要:农夫知道一头牛的位置,想要抓住它。农夫和牛都于数轴上 ,农夫起始位于点 N(0<=N<=100000) ,牛位于点 K(0<=K<=100000) 。农夫有两种移动方式: 1、从 X移动到 X-1或X+1 ,每次移动花费一分钟 2、从 X移动到 2*X ,每次移动花费一分钟 假设牛没有意识到农夫的行 阅读全文
posted @ 2019-07-23 22:02 Target--fly 阅读(288) 评论(0) 推荐(0)

摘要:Many of us had played the game "Battle city" in our childhood, and some people (like me) even often play it on computer now. What we are discussing is 阅读全文
posted @ 2019-07-23 21:55 Target--fly 阅读(168) 评论(0) 推荐(0)

摘要:There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he c 阅读全文
posted @ 2019-07-23 21:50 Target--fly 阅读(223) 评论(0) 推荐(0)

摘要:思路 : 优先队列 每次都取最小的时间,遇到了终点直接就输出#include #include #include using namespace std; const int N=200; int n,m,sa,ea,sr,er; char arr[N][N]; int bb[N][N]={0}; struct stu{ int a,b; int time; ... 阅读全文
posted @ 2019-07-23 13:26 Target--fly 阅读(154) 评论(0) 推荐(0)

摘要:我们规定一个人是复读机当且仅当他说的每一句话都是复读前一个人说的话。 我们规定一个人是复读机当且仅当他说的每一句话都是复读前一个人说的话。 我们规定一个人是复读机当且仅当他说的每一句话都是复读前一个人说的话。 规定一个复读机的熟练度为复读数量的多少。现在给你一段聊天记录,请你找出其中的复读机们。 规 阅读全文
posted @ 2019-07-22 08:52 Target--fly 阅读(200) 评论(0) 推荐(0)

摘要:1 algorithml中的find,还有就是string中的find 对对于第一种其调用形式为 find(start,end,value) start搜寻的起点,end搜寻的终点,要寻找的value值 容器的表示方法 find(a.begin(),a.end(),value) (在对迭代器使用fi 阅读全文
posted @ 2019-07-21 21:57 Target--fly 阅读(1019) 评论(0) 推荐(0)

摘要:一、概念 从n个不同元素中任取m(m≤n)个元素,按照一定的顺序排列起来,叫做从n个不同元素中取出m个元素的一个排列。当m=n时所有的排列情况叫全排列。如果这组数有n个,那么全排列数为n!个。 比如a,b,c的全排列一共有3!= 6 种 分别是{a, b, c}、{a, c, b}、{b, a, c 阅读全文
posted @ 2019-07-21 21:23 Target--fly 阅读(616) 评论(0) 推荐(0)

摘要:1在使用STL时,由于解题的需要我们常常将结构体嵌入到字典或者集合中,,如果我们这样写: struct stu{ int a; int b; }; mp<stu,int >mp; 在编译的时候会报错,,因为map和set会对STL中的元素排序,如果说直接嵌入的话,, 会使map无法对key进行排序, 阅读全文
posted @ 2019-07-21 21:06 Target--fly 阅读(135) 评论(0) 推荐(0)

摘要:STL的迭代器听起来怪吓人的,其实并不是什么高深的东西,说白了就是定义了一个指向STL的指针。、 对于没个STIL都可以定义 set,,vector ,,map,,,string 定义: set<int >::iterator it;(以set与int为例) 可以用于遍历set中的元素 比如 这样就 阅读全文
posted @ 2019-07-21 20:34 Target--fly 阅读(282) 评论(0) 推荐(0)

摘要:给出N个数,要求把其中重复的去掉,只保留第一次出现的数。 例如,给出的数为1 2 18 3 3 19 2 3 6 5 4,其中2和3有重复,去除后的结果为1 2 18 3 19 6 5 4。 Input 输入第一行为正整数T,表示有T组数据。 接下来每组数据包括两行,第一行为正整数N,表示有N个数。 阅读全文
posted @ 2019-07-19 23:08 Target--fly 阅读(271) 评论(0) 推荐(0)

摘要:There is a famous railway station in PopPush City. Country there is incredibly hilly. The station was built in last century. Unfortunately, funds were 阅读全文
posted @ 2019-07-19 22:54 Target--fly 阅读(151) 评论(0) 推荐(0)

摘要:As the new term comes, the Ignatius Train Station is very busy nowadays. A lot of student want to get back to school by train(because the trains in th 阅读全文
posted @ 2019-07-19 22:49 Target--fly 阅读(193) 评论(0) 推荐(0)

摘要:这个题目套公式 2^(n-1)-1,再来个快速幂基本上就可以AC了 写这个题目的: 公式容易推到错: 容易写成 2^n-1/2。。。这样写出来结果也不错 但是一直哇 AC: #include<iostream> #include<cstdio> #include<cstring> #define N 阅读全文
posted @ 2019-07-19 22:31 Target--fly 阅读(109) 评论(0) 推荐(0)

摘要:小明对数的研究比较热爱,一谈到数,脑子里就涌现出好多数的问题,今天,小明想考考你对素数的认识。 问题是这样的:一个十进制数,如果是素数,而且它的各位数字和也是素数,则称之为“美素数”,如29,本身是素数,而且2+9 = 11也是素数,所以它是美素数。 给定一个区间,你能计算出这个区间内有多少个美素数 阅读全文
posted @ 2019-07-19 22:24 Target--fly 阅读(272) 评论(0) 推荐(0)

摘要:There is a hill with n holes around. The holes are signed from 0 to n-1. A rabbit must hide in one of the holes. A wolf searches the rabbit in anticlo 阅读全文
posted @ 2019-07-19 22:14 Target--fly 阅读(196) 评论(0) 推荐(0)

摘要:People are different. Some secretly read magazines full of interesting girls' pictures, others create an A-bomb in their cellar, others like using Win 阅读全文
posted @ 2019-07-19 22:11 Target--fly 阅读(152) 评论(0) 推荐(0)

摘要:队列和栈的头文件以及常用函数 #include<stack> 先进后出 using namespace std; stack <类型> s(变量); s.pop() 删除栈顶元素 s.empty() 判断栈是否为空,为空返回1 s.push(i) 将i压入栈中 s.top() 返回栈顶元素 s.si 阅读全文
posted @ 2019-07-18 23:31 Target--fly 阅读(138) 评论(0) 推荐(0)

摘要:埃氏筛法 o(nlogn) prim[1]=1; for(int i=2;i<=maxn1;i++) if(!prim[i]) { for(int j=2*i;j<=maxn1;j+=i) prim[j]=1; } 欧拉筛法o(n) void inint(){ prime[1]=1; int num 阅读全文
posted @ 2019-07-18 20:11 Target--fly 阅读(185) 评论(0) 推荐(0)

摘要:Given a sequence 1,2,3,......N, your job is to calculate all the possible sub-sequences that the sum of the sub-sequence is M. InputInput contains mul 阅读全文
posted @ 2019-07-18 16:56 Target--fly 阅读(245) 评论(0) 推荐(1)

摘要:Limak is a little polar bear. He has n balls, the i-th ball has size ti. Limak wants to give one ball to each of his three friends. Giving gifts isn't 阅读全文
posted @ 2019-07-18 16:35 Target--fly 阅读(152) 评论(0) 推荐(0)

摘要:“Point, point, life of student!” This is a ballad(歌谣)well known in colleges, and you must care about your score in this exam too. How many points can 阅读全文
posted @ 2019-07-18 16:32 Target--fly 阅读(151) 评论(0) 推荐(0)