- 博客(35)
- 资源 (2)
- 收藏
- 关注
原创 gym101810
B - Friends and Cookies 找规律,除了第一项以外 ,发现它是2*(n-1)项一循环,根据规律进行处理。因为把–写成++,错交好多发,吐血。。。#include<iostream>#define ll unsigned long longusing namespace std;ll a[10005];int main(){ std::ios...
2018-07-31 10:24:32
372
原创 最小字段和/最小正子段和/最大连续子段和(待更)
最小正子段和 对前缀和由小到大排序,在相邻位置的差中一定存在最终结果。#include<iostream>#include<algorithm>using namespace std;int n;struct node{ long long val; int pos;};node a[50005];bool cmp(node a,nod...
2018-06-02 23:19:46
1172
原创 D-query
Description Given a sequence of n numbers a1, a2, …, an and a number of d-queries. A d-query is a pair (i, j) (1 ≤ i ≤ j ≤ n). For each d-query (i, j), you have to return the number of distinct eleme...
2018-05-19 22:46:10
255
原创 小Z的袜子(hose)
Description 作为一个生活散漫的人,小Z每天早上都要耗费很久从一堆五颜六色的袜子中找出一双来穿。终于有一天,小Z再也无法忍受这恼人的找袜子过程,于是他决定听天由命…… 具体来说,小Z把这N只袜子从1到N编号,然后从编号L到R(L 尽管小Z并不在意两只袜子是不是完整的一双,甚至不在意两只袜子是否一左一右,他却很在意袜子的颜色,毕竟穿两只不同色的袜子会很尴尬。 你的任务便是告诉小Z,他...
2018-05-19 22:39:27
180
原创 Little Elephant and Array
Description The Little Elephant loves playing with arrays. He has array a, consisting of n positive integers, indexed from 1 to n. Let’s denote the number with index i as ai. Additionally the Littl...
2018-05-19 22:35:44
510
原创 德玛西亚万岁
链接:https://www.nowcoder.com/acm/contest/74/F 来源:牛客网题目描述 德玛西亚是一个实力雄厚、奉公守法的国家,有着功勋卓著的光荣军史。这里非常重视正义、荣耀、职责的意识形态,这里的人民为此感到强烈自豪。有一天他们想去制裁邪恶的比尔吉沃特,于是派遣了自己最优秀的战士。结果比尔吉沃特领土太小,只有长为n宽为m共计n*m块土地,
2018-02-02 18:29:28
879
原创 poj3140:Contestants Division
Problem Description In the new ACM-ICPC Regional Contest, a special monitoring and submitting system will be set up, and students will be able to compete at their own universities. However there’s on
2018-02-01 11:54:44
227
原创 poj3107:Godfather
Problem Description Last years Chicago was full of gangster fights and strange murders. The chief of the police got really tired of all these crimes, and decided to arrest the mafia leaders.Unfortu
2018-01-31 11:22:01
251
原创 hdu2196:Computer
Problem Description A school bought the first computer some time ago(so this computer’s id is 1). During the recent years the school bought N-1 new computers. Each new computer was connected to one o
2018-01-30 17:45:39
249
原创 hdu1520:Anniversary party
Problem Description There is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure of employees. It means that the superviso
2018-01-30 11:36:06
181
原创 算法训练:安慰奶牛
解题思路 此题很明显是一个求最小生成树的问题,关键在于如果处理图上边的权值。因为我从七点出发,最终还要沿原路返回起点,所以树上的边皆走过两次。因为每走过一条边都要经过由该边相连的两邻接点,所以最终的权值还要加上两邻接点的权值。一开始我很疑惑点和边同样也要遍历两次为什么不需要乘2。后来发现我们在计算每一条边时都加上了邻接点的权值,所以实际上所有的分支结点都算了两次。通过模拟我们也可以知道在遍历过程
2018-01-23 18:50:52
237
原创 算法训练:k好数
解题思路 提示里说这是一个dp问题。建一个二维数组,令dp[i][j]表示前i位中第i位的数为j的方案数,状态转移方程为dp[i][j]=dp[i-1][p](p为不与j相邻的任意数)。最后的所求结果为dp[l][i:0–k-1],即前l位以0到k-1为最后一位数的所有方案数之和。代码#includeusing namespace std;#define mod 10000000
2018-01-23 11:44:02
432
1
原创 寒假训练01G:hdu1260
Problem Description Jesus, what a great movie! Thousands of people are rushing to the cinema. However, this is really a tuff time for Joe who sells the film tickets. He is wandering when could he go
2018-01-21 18:02:08
379
原创 算法训练 最大最小公倍数
问题描述 已知一个正整数N,问从1~N中任选出三个数,他们的最小公倍数最大可以为多少。输入格式 输入一个正整数N。输出格式 输出一个整数,表示你找到的最小公倍数。样例输入 9样例输出 504数据规模与约定 1 题解: http://blog.youkuaiyun.com/ljd4305/article/details/21177485 (PS:据说后台数据部分有错误的样
2018-01-19 10:35:32
221
原创 寒假训练01E:hdu1087
Problem Description Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this game, so I introduce it to yo
2018-01-18 18:25:53
286
原创 寒假训练01C:hdu1069
Problem Description A group of researchers are designing an experiment to test the IQ of a monkey. They will hang a banana at the roof of a building, and at the mean time, provide the monkey with som
2018-01-18 17:21:41
207
原创 寒假训练01B:hdu1029
Problem Description “OK, you are not too bad, em… But you can never pass the next test.” feng5166 says.“I will tell you an odd number N, and then N integers. There will be a special integer among t
2018-01-17 18:16:03
240
转载 Coneology(poj2932)
Description A student named Round Square loved to play with cones. He would arrange cones with different base radii arbitrarily on the floor and would admire the intrinsic beauty of the arrangement. T
2017-11-25 00:39:49
254
原创 Jack Straws
Description In the game of Jack Straws, a number of plastic or wooden “straws” are dumped on the table and players try to remove them one-by-one without disturbing the other straws. Here, we are only
2017-11-18 00:06:18
387
原创 Boolean expressions
描述 The objective of the program you are going to produce is to evaluate boolean expressions as the one shown next: Expression: ( V | V ) & F & ( F | V )where V is for True, and F is for False. The e
2017-11-07 08:33:20
1263
原创 鸣人的影分身
描述 佐助被大蛇丸诱骗走了,鸣人在多少时间内能追上他呢? 已知一张地图(以二维矩阵的形式表示)以及佐助和鸣人的位置。地图上的每个位置都可以走到,只不过有些位置上有大蛇丸的手下,需要先打败大蛇丸的手下才能到这些位置。鸣人有一定数量的查克拉,每一个单位的查克拉可以打败一个大蛇丸的手下。假设鸣人可以往上下左右四个方向移动,每移动一个距离需要花费1个单位时间,打败大蛇丸的手下不需要时间。如果鸣人查克拉消
2017-11-07 07:41:16
228
转载 POJ2135:Farm Tour
Description When FJ’s friends visit him on the farm, he likes to show them around. His farm comprises N (1 <= N <= 1000) fields numbered 1..N, the first of which contains his house and the Nth of whic
2017-11-06 23:13:42
451
转载 POJ3469:Dual Core CPU
Description As more and more computers are equipped with dual core CPU, SetagLilb, the Chief Technology Officer of TinySoft Corporation, decided to update their famous product - SWODNIW. The routine
2017-11-05 22:46:50
159
转载 POJ3281:Dining
Description Cows are such finicky eaters. Each cow has a preference for certain foods and drinks, and she will consume no others. Farmer John has cooked fabulous meals for his cows, but he forgot to
2017-11-05 16:52:17
194
转载 Asteroids
Description Bessie 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 conveni
2017-11-05 15:20:31
177
原创 Sudoku
描述 Sudoku is a very simple task. A square table with 9 rows and 9 columns is divided to 9 smaller squares 3x3 as shown on the Figure. In some of the cells are written decimal digits from 1 to 9. The o
2017-10-05 18:41:59
409
转载 poj3684:Physics Experiment
Description Simon is doing a physics experiment with N identical balls with the same radius of R centimeters. Before the experiment, all N balls are fastened within a vertical tube one by one and the
2017-10-05 18:11:11
283
转载 poj3279:Fliptile
DescriptionFarmer John knows that an intellectually satisfied cow is a happy cow who will give more milk. He has arranged a brainy activity for cows in which they manipulate an M × N grid (1 ≤ M ≤ 15;
2017-10-05 17:35:40
172
原创 zoj1610:count the colors
Description Painting some colored segments on a line, some previously painted segments may be covered by some the subsequent ones. Your task is counting the segments of different colors you can see a
2017-10-05 13:27:47
300
原创 poj3468:A Simple Problem with Integers
Description: You have N integers, A1, A2, … , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other is to a
2017-10-05 12:26:45
278
转载 poj3276:Face The Right Way
DescriptionFarmer John has arranged his N (1 ≤ N ≤ 5,000) cows in a row and many of them are facing forward, like good cows. Some of them are facing backward, though, and he needs them all to face forw
2017-10-05 11:37:44
239
转载 poj3320:Jessica's Reading Problem
DescriptionJessica’s a very lovely girl wooed by lots of boys. Recently she has a problem. The final exam is coming, yet she has spent little time on it. If she wants to pass it, she has to master all
2017-10-05 10:58:00
233
原创 poj3061:Subsequence
DescriptionA 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
2017-10-05 10:29:24
188
原创 hdu1754:I hate it
题目描述: 很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。 这让很多学生很反感。 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。Input 题目包含多组测试,请处理到文件结束。 在每个测试的第一行,有两个正整数 N 和 M ( 0小于N<=200000,0小于M<5000 ),分
2017-10-05 09:32:21
215
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人