随笔分类 -  ACM练习题

摘要:题目:HDU5954 题意: 奶牛报数,先给两个数a和b,分别是f[n-2],f[n-1],之后每头奶牛i报数为f[i-1] + 2 * f[i-2] + i^4;给出n,求din头奶牛要报的数字,对2147493647取余。 思路: 看到这个式子知道这是一个矩阵快速幂,然后开始推式子,在我给队友写 阅读全文
posted @ 2018-10-10 23:08 sykline 阅读(326) 评论(0) 推荐(0)
摘要:题目: 算术表达式有前缀表示法、中缀表示法和后缀表示法等形式。日常使用的算术表达式是采用中缀表示法,即二元运算符位于两个运算数中间。请设计程序将中缀表达式转换为后缀表达式。 输入格式: 输入在一行中给出不含空格的中缀表达式,可包含+、-、*、\以及左右括号(),表达式不超过20个字符。 输出格式: 阅读全文
posted @ 2018-10-09 20:13 sykline 阅读(7914) 评论(0) 推荐(0)
摘要:题目: The gaming company Sandstorm is developing an online two player game. You have been asked to implement the ranking system. All players have a rank 阅读全文
posted @ 2018-10-08 17:56 sykline 阅读(224) 评论(0) 推荐(0)
摘要:题目: A tremendously exciting raffle is being held, with some tremendously exciting prizes being given out. All you have to do to have a chance of being 阅读全文
posted @ 2018-10-08 17:33 sykline 阅读(229) 评论(0) 推荐(0)
摘要:题目: Gina Reed, the famous stockbroker, is having a slow day at work, and between rounds of solitaire she is daydreaming. Foretelling the future is har 阅读全文
posted @ 2018-10-07 22:57 sykline 阅读(326) 评论(0) 推荐(0)
摘要:题目: 请编写程序检查C语言源程序中下列符号是否配对:/*与*/、(与)、[与]、{与}。 输入格式: 输入为一个C语言源程序。当读到某一行中只有一个句点.和一个回车的时候,标志着输入结束。程序中需要检查配对的符号不超过100个。 输出格式: 首先,如果所有符号配对正确,则在第一行中输出YES,否则 阅读全文
posted @ 2018-10-06 22:16 sykline 阅读(9510) 评论(0) 推荐(0)
摘要:题目: Mr. Panda likes ice cream very much especially the ice cream tower. An ice cream tower consists of K ice cream balls stacking up as a tower. In or 阅读全文
posted @ 2018-10-06 18:44 sykline 阅读(379) 评论(0) 推荐(0)
摘要:题目: The Codejamon game is on fire! Fans across the world are predicting and betting on which team will win the game. A gambling company is providing b 阅读全文
posted @ 2018-10-06 16:46 sykline 阅读(665) 评论(0) 推荐(0)
摘要:题目: Here is World Cup again, the top 32 teams come together to fight for the World Champion. The teams are assigned into 8 groups, with 4 teams in eac 阅读全文
posted @ 2018-10-06 15:50 sykline 阅读(338) 评论(0) 推荐(0)
摘要:题目: Mr. Panda is one of the top specialists on number theory all over the world. Now Mr. Panda is investigating the property of the powers of 2. Since 阅读全文
posted @ 2018-10-06 15:32 sykline 阅读(280) 评论(0) 推荐(0)
摘要:题目: A clique is a complete graph, in which there is an edge between every pair of the vertices. Given a graph with N vertices and M edges, your task i 阅读全文
posted @ 2018-10-05 19:10 sykline 阅读(178) 评论(0) 推荐(0)
摘要:Problem Description: A mysterious circular arrangement of black stones and white stones has appeared. Ming has been tasked with balancing the stones s 阅读全文
posted @ 2018-10-04 18:21 sykline 阅读(226) 评论(0) 推荐(0)
摘要:HDU5894—Pocky Problem Description: Let’s talking about something of eating a pocky. Here is a Decorer Pocky, with colorful decorative stripes in the c 阅读全文
posted @ 2018-10-04 10:53 sykline 阅读(232) 评论(0) 推荐(0)
摘要:题目传送门:Be Efficient 题意:输入n和m,然后输入有n个元素的一个序列,问有多少个子序列元素的和能整除m。 思路:求前缀和,利用一个前缀的一个定理求解。 前缀和的一个定理是:每次求的前缀和对m取余,两个相等的结果之间的序列的和就是m的倍数。 如上序号1、4的结果相同,则序号2、3、4的 阅读全文
posted @ 2018-10-02 19:55 sykline 阅读(324) 评论(0) 推荐(0)
摘要:Select Of Chocolate Poles 题意:有一个竖直放置的高度为l cm的盒子,现在有三种方块分别为1cm的白块,1cm的黑块,k cm的黑块,要求第一块放进去的必须是黑色的,盒子最上边的必须也是黑色的,盒子不必放满,问一共有多少种放法。 思路:知道要用DP确实死活推不出状态转移公式 阅读全文
posted @ 2018-10-02 19:54 sykline 阅读(158) 评论(0) 推荐(0)
摘要:平行直线 题意:给出一些点,这些点两两相连成一条直线,问最多能连成多少条直线。 思路:暴力出奇迹!!记得当时比赛做这道题的时候一直依赖于板子,结果却限制了自己的思路,这得改。dfs直接暴力,但是需要将已经走过的点标记一下,用一个循环跳过已经标记的点减少dfs次数,不然得不出正确的结果,因为会出现如下 阅读全文
posted @ 2018-10-02 19:54 sykline 阅读(148) 评论(0) 推荐(0)
摘要:Decoding of Varints ​ 题意&思路: 首先根据红色边框部分的公式算出x,再有绿色部分得知,如果x是偶数则直接除以2,x是奇数则(x+1)/-2。 PS:这题有数据会爆掉unsigned long long,就是在最后奇数转换的时候。所以转换的时候可以变公式为-((x-1)/2+1 阅读全文
posted @ 2018-10-02 19:53 sykline 阅读(348) 评论(0) 推荐(0)
摘要:除留余数法设计哈希表 : 由该式子得到value在哈希表中的存储位置:index = value % p;这里为了尽量的减少冲突,而且让value在哈希表中尽可能的均匀分布,p的选择就至关重要了。而合理选择p的经验是:若散列表表长为m,通常p为小于或等于表长(最好接近m)的最小质数或不包含小于20质 阅读全文
posted @ 2018-10-02 19:52 sykline 阅读(1608) 评论(0) 推荐(0)
摘要:题意: ​ 思路:单源最短路问题,Dijkstra算法搞定就可以了,因为要找出最便宜的最短路,所以需要在更新最短距离的时候加一个条件(即当最短距离相等的时候,如果该路径的花费更小,就更新最小花费)就可以了。之前自己学的最短路的水平也就仅限于模板题的水平,现在可以在条件上稍微加一些变化,做了数据结构的 阅读全文
posted @ 2018-10-02 19:51 sykline 阅读(1197) 评论(0) 推荐(0)
摘要:题意: 思路: 用优先队列直接模拟就OK了,另外优先队列存pair的时候比较的是first的值,实测!! 上代码: 1 #include <iostream> 2 #include <queue> 3 #include <cstdio> 4 #include <algorithm> 5 #inclu 阅读全文
posted @ 2018-10-02 19:50 sykline 阅读(267) 评论(0) 推荐(0)