11 2018 档案

摘要:【题目描述】给定N个数,求这N个数的最长上升子序列的长度。【样例输入】72 5 3 4 1 7 6【样例输出】4 什么是最长上升子序列? 就是给你一个序列,请你在其中求出一段不断严格上升的部分,它不一定要连续。就像这样:2,3,4,7和2,3,4,6就是序列2 5 3... 阅读全文
posted @ 2018-11-30 17:59 black_hole6 阅读(550) 评论(0) 推荐(0) 编辑
摘要:【题目描述】给定N个数,求这N个数的最长上升子序列的长度。【样例输入】72 5 3 4 1 7 6【样例输出】4 什么是最长上升子序列? 就是给你一个序列,请你在其中求出一段不断严格上升的部分,它不一定要连续。就像这样:2,3,4,7和2,3,4,6就是序列2 5 3... 阅读全文
posted @ 2018-11-30 17:29 black_hole6 阅读(122) 评论(0) 推荐(0) 编辑
摘要:The people of Mohammadpur have decided to paint each of their houses red, green, or blue. They've also decided that no two neighboring... 阅读全文
posted @ 2018-11-30 11:08 black_hole6 阅读(115) 评论(0) 推荐(0) 编辑
摘要:Given an integer nn, we only want to know the sum of 1/k21/k2 where kk from 11 to nn.InputThere are multiple cases. For each test case... 阅读全文
posted @ 2018-11-29 22:58 black_hole6 阅读(101) 评论(0) 推荐(0) 编辑
摘要:我们看到过很多直线分割平面的题目,今天的这个题目稍微有些变化,我们要求的是n条折线分割平面的最大数目。比如,一条折线可以将平面分成两部分,两条折线最多可以将平面分成7部分,具体如下所示。 Input输入数据的第一行是一个整数C,表示测试实例的个数,然后是C 行数据,每... 阅读全文
posted @ 2018-11-29 22:49 black_hole6 阅读(183) 评论(0) 推荐(0) 编辑
摘要:题目背景AA地区在地震过后,连接所有村庄的公路都造成了损坏而无法通车。政府派人修复这些公路。题目描述给出A地区的村庄数NN,和公路数MM,公路是双向的。并告诉你每条公路的连着哪两个村庄,并告诉你什么时候能修完这条公路。问最早什么时候任意两个村庄能够通车,即最早什么时候... 阅读全文
posted @ 2018-11-29 16:41 black_hole6 阅读(272) 评论(0) 推荐(0) 编辑
摘要:欧拉回路是指不令笔离开纸面,可画过图中每条边仅一次,且可以回到起点的一条回路。现给定一个图,问是否存在欧拉回路?Input测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数,分别是节点数N ( 1 #include#include#includeusing ... 阅读全文
posted @ 2018-11-29 15:43 black_hole6 阅读(272) 评论(0) 推荐(0) 编辑
摘要:题目描述也许你早就知道阶乘的含义,N阶乘是由1到N相乘而产生,如:12!= 1 \times 2 \times 3 \times 4 \times 5 \times 6 \times 7 \times 8 \times 9 \times 10 \times 11 \t... 阅读全文
posted @ 2018-11-29 12:16 black_hole6 阅读(215) 评论(0) 推荐(0) 编辑
摘要:时间限制 3000 ms 内存限制 32768 KB 代码长度限制 100 KB 判断程序 Standard (来自 小小)题目描述NowCoder号称自己已经记住了1-100000之间所有的斐波那契数。为了考验他,我们随便出一个数n,让他说出第n个斐波那契数。当然,... 阅读全文
posted @ 2018-11-28 20:30 black_hole6 阅读(371) 评论(0) 推荐(0) 编辑
摘要:时间限制 3000 ms 内存限制 32768 KB 代码长度限制 100 KB 题目描述NowCoder最近在研究一个数列:* F(0) = 7* F(1) = 11* F(n) = F(n-1) + F(n-2) (n≥2)他称之为NowCoder数列。请你帮忙确... 阅读全文
posted @ 2018-11-27 22:43 black_hole6 阅读(241) 评论(0) 推荐(0) 编辑
摘要:题目描述对一个给定的自然数MM,求出所有的连续的自然数段,这些连续的自然数段中的全部数之和为MM。例子:1998+1999+2000+2001+2002 = 100001998+1999+2000+2001+2002=10000,所以从19981998到2002200... 阅读全文
posted @ 2018-11-27 09:37 black_hole6 阅读(208) 评论(0) 推荐(0) 编辑
摘要:题目描述输入22个正整数x_0,y_0(2 \le x_0#include#include#includeusing namespace std;int main(){ int n,m; int cnt=0; cin>>n>>m; for(int t=n;t<=m;... 阅读全文
posted @ 2018-11-26 21:38 black_hole6 阅读(283) 评论(1) 推荐(0) 编辑
摘要:Diophantus of Alexandria was an egypt mathematician living in Alexandria. He was one of the first mathematicians to study equations wh... 阅读全文
posted @ 2018-11-26 20:32 black_hole6 阅读(165) 评论(0) 推荐(0) 编辑
摘要:题目描述如题,给定一个范围N,你需要处理M个某数字是否为质数的询问(每个数字均在范围1-N内)输入输出格式输入格式: 第一行包含两个正整数N、M,分别表示查询的范围和查询的个数。接下来M行每行包含一个不小于1且不大于N的整数,即询问该数是否为质数。 输出格式: 输出包... 阅读全文
posted @ 2018-11-26 18:49 black_hole6 阅读(646) 评论(1) 推荐(1) 编辑
摘要:欧拉函数 编辑在数论,对正整数n,欧拉函数是小于n的正整数中与n互质的数的数目(φ(1)=1)。此函数以其首名研究者欧拉命名(Euler's totient function),它又称为Euler's totient function、φ函数、欧拉商数等。 例如φ(8... 阅读全文
posted @ 2018-11-25 17:43 black_hole6 阅读(185) 评论(0) 推荐(0) 编辑
摘要:当你试图登录某个系统却忘了密码时,系统一般只会允许你尝试有限多次,当超出允许次数时,账号就会被锁死。本题就请你实现这个小功能。输入格式:输入在第一行给出一个密码(长度不超过 20 的、不包含空格、Tab、回车的非空字符串)和一个正整数 N(≤ 10),分别是正确的密码... 阅读全文
posted @ 2018-11-25 13:14 black_hole6 阅读(141) 评论(0) 推荐(0) 编辑
摘要:Little girl Margarita is a big fan of competitive programming. She especially loves problems about arrays and queries on them. Recently, she was prese 阅读全文
posted @ 2018-11-24 17:12 black_hole6 阅读(244) 评论(0) 推荐(0) 编辑
摘要:Petya is having a party soon, and he has decided to invite his nn friends. He wants to make invitations in the form of origami. For each invitation, h 阅读全文
posted @ 2018-11-24 17:11 black_hole6 阅读(229) 评论(0) 推荐(0) 编辑
摘要:Little girl Margarita is a big fan of competitive programming. She especially loves problems about arrays and queries on them.Recently... 阅读全文
posted @ 2018-11-24 17:05 black_hole6 阅读(134) 评论(0) 推荐(0) 编辑
摘要:Petya is having a party soon, and he has decided to invite his nn friends.He wants to make invitations in the form of origami. For eac... 阅读全文
posted @ 2018-11-24 17:02 black_hole6 阅读(103) 评论(0) 推荐(0) 编辑
摘要:要求(A/B)%9973,但由于A很大,我们只给出n(n=A%9973)(我们给定的A必能被B整除,且gcd(B,9973) = 1)。Input数据的第一行是一个T,表示有T组数据。 每组数据有两个数n(0 #include#include#includeint m... 阅读全文
posted @ 2018-11-24 12:13 black_hole6 阅读(160) 评论(0) 推荐(0) 编辑
摘要:算术基本定理,又称为正整数的唯一分解定理,即:每个大于1的自然数,若不是本身就是质数,就是可写为2个以上的质数的积,而且这些质因子按大小排列之后,写法仅有一种方式。例如:{\displaystyle 6936=2^{3}\times 3\times 17^{2}},{... 阅读全文
posted @ 2018-11-24 10:04 black_hole6 阅读(1745) 评论(0) 推荐(0) 编辑
摘要:__gcd()函数是内置于algorithm头文件中的函数,主要是用于求两个数的最大公约数,这是这个函数主要是这个功能: 下面是代码十分简单 阅读全文
posted @ 2018-11-23 22:47 black_hole6 阅读(17930) 评论(0) 推荐(5) 编辑
摘要:time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output time limit per test 2 seconds time limit 阅读全文
posted @ 2018-11-23 00:16 black_hole6 阅读(211) 评论(0) 推荐(0) 编辑
摘要:Andy, 8, has a dream - he wants to produce his very own dictionary. This is not an easy task for him, as the number of words that he k... 阅读全文
posted @ 2018-11-22 10:55 black_hole6 阅读(114) 评论(0) 推荐(0) 编辑
摘要:1967年,美国著名的社会学家斯坦利·米尔格兰姆提出了一个名为“小世界现象(small world phenomenon)”的著名假说,大意是说,任何2个素不相识的人中间最多只隔着6个人,即只用6个人就可以将他们联系在一起,因此他的理论也被称为“六度分离”理论(six... 阅读全文
posted @ 2018-11-20 18:59 black_hole6 阅读(709) 评论(0) 推荐(0) 编辑
摘要:Folyd算法适合多源最短路的求解问题(时间复杂度(O(n^3)),单源无负权值的问题适合Dijstra(O(n^2))小Hi强行装作没听到,继续说道:“这个算法的核心之处在于数学归纳法——MinDistance(i, j)之间最短路径中可以用到的节点是一点点增加的... 阅读全文
posted @ 2018-11-20 11:42 black_hole6 阅读(298) 评论(0) 推荐(0) 编辑
摘要:Dijkstra算法 Dijkstra算法算是贪心思想实现的,首先把起点到所有点的距离存下来找个最短的,然后松弛一次再找出最短的,所谓的松弛操作就是,遍历一遍看通过刚刚找到的距离最短的点作为中转站会不会更近,如果更近了就更新距离,这样把所有的点找遍之后就存下了起点到其... 阅读全文
posted @ 2018-11-20 09:20 black_hole6 阅读(12251) 评论(0) 推荐(1) 编辑
摘要:Bessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Be 阅读全文
posted @ 2018-11-20 08:51 black_hole6 阅读(213) 评论(0) 推荐(0) 编辑
摘要:Bessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the mor... 阅读全文
posted @ 2018-11-19 23:12 black_hole6 阅读(305) 评论(0) 推荐(0) 编辑
摘要:One cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1..N is going to attend the big cow party to be held at farm #X (1 ≤... 阅读全文
posted @ 2018-11-19 19:00 black_hole6 阅读(148) 评论(0) 推荐(0) 编辑
摘要:Freddy 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... 阅读全文
posted @ 2018-11-18 10:18 black_hole6 阅读(99) 评论(0) 推荐(0) 编辑
摘要:对于删除操作,在完美的并查集中(所有节点都直接连接在根节点上),理论上只要把要删除的节点的上级重新指向自己就可以了。但是实际情况中,我们的并查集形成的树的形态都是不可预估形态的,如果直接将一个节点指向自己可能会将他的“下级”和他一起删除,这就和我们的想法违背了。所以在... 阅读全文
posted @ 2018-11-17 08:48 black_hole6 阅读(609) 评论(0) 推荐(1) 编辑
摘要:DescriptionThere are N villages, which are numbered from 1 to N, and you should build some roads such that every two villages can conn... 阅读全文
posted @ 2018-11-15 00:04 black_hole6 阅读(121) 评论(0) 推荐(0) 编辑
摘要:Description There are N villages, which are numbered from 1 to N, and you should build some roads such that every two villages can connect to each oth 阅读全文
posted @ 2018-11-15 00:01 black_hole6 阅读(121) 评论(0) 推荐(0) 编辑
摘要:Our lovely KK has a difficult Social problem.A big earthquake happened in his area.N(2≤N≤2000)N(2≤N≤2000) cities have been implicated. All the roads b 阅读全文
posted @ 2018-11-14 00:31 black_hole6 阅读(101) 评论(0) 推荐(0) 编辑
摘要:Our lovely KK has a difficult Social problem.A big earthquake happened in his area.N(2≤N≤2000)N(2≤N≤2000) cities have been implicated.... 阅读全文
posted @ 2018-11-14 00:29 black_hole6 阅读(190) 评论(0) 推荐(0) 编辑
摘要:Economic times these days are tough, even in Byteland. To reduce the operating costs, the government of Byteland has decided to optimi... 阅读全文
posted @ 2018-11-13 22:19 black_hole6 阅读(137) 评论(0) 推荐(0) 编辑
摘要:Economic times these days are tough, even in Byteland. To reduce the operating costs, the government of Byteland has decided to optimize the road ligh 阅读全文
posted @ 2018-11-13 21:50 black_hole6 编辑
摘要:time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputou are given a string ss consisti... 阅读全文
posted @ 2018-11-12 23:41 black_hole6 阅读(155) 评论(0) 推荐(0) 编辑
摘要:A. Minimizing the String time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a 阅读全文
posted @ 2018-11-12 23:37 black_hole6 阅读(323) 评论(3) 推荐(2) 编辑
摘要:相信大家都听说一个“百岛湖”的地方吧,百岛湖的居民生活在不同的小岛中,当他们想去其他的小岛时都要通过划小船来实现。现在政府决定大力发展百岛湖,发展首先要解决的问题当然是交通问题,政府决定实现百岛湖的全畅通!经过考察小组RPRush对百岛湖的情况充分了解后,决定在符合条... 阅读全文
posted @ 2018-11-12 09:41 black_hole6 阅读(130) 评论(0) 推荐(0) 编辑
摘要:某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路?Input测试输入包含若干测试用例。每个... 阅读全文
posted @ 2018-11-11 18:49 black_hole6 阅读(129) 评论(0) 推荐(0) 编辑
摘要:并查集由一个整数型的数组和两个函数构成。数组pre[]记录了每个点的前导点是什么,函数find是查找,join是合并。int pre[1000 ];int find(int x) //查找根节... 阅读全文
posted @ 2018-11-11 18:47 black_hole6 阅读(227) 评论(0) 推荐(0) 编辑
摘要:某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离。省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可),并要求铺设的公路总长度为最小。请计算最小的公路总长度。Input测试输入包含若干测试... 阅读全文
posted @ 2018-11-11 18:42 black_hole6 阅读(124) 评论(0) 推荐(0) 编辑
摘要:关于计算基础问题华氏度与摄氏度互相转化问题 题目内容: 写一个将华氏温度转换成摄氏温度的程序,转换的公式是: °F = (9/5)*°C + 32 其中C表示摄氏温度,F表示华氏温度。 程序的输入是一个整数,表示华氏温度。输出对应的摄氏温度,也是一个整数。 输入格式: 一个整数。 输出格式: 一个整 阅读全文
posted @ 2018-11-11 18:36 black_hole6 阅读(276) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2018-11-10 17:00 black_hole6 阅读(124) 评论(0) 推荐(0) 编辑
摘要:某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离。省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可),并要求铺设的公路总长度为最小。请计算最小的公路总长度。 Input测试输入包含若干测试用例。每个测试用例的第1行给出 阅读全文
posted @ 2018-11-10 16:58 black_hole6 阅读(125) 评论(0) 推荐(0) 编辑
摘要:并查集由一个整数型的数组和两个函数构成。数组pre[]记录了每个点的前导点是什么,函数find是查找,join是合并。 为了解释并查集的原理,我将举一个有爱的例子。 话说江湖上散落着各式各样的大侠,有上千个之多。他们没有什么正当职业,整天背着剑在外面走来走去,碰到和自己不是一路人的,就免不了要打一架 阅读全文
posted @ 2018-11-09 23:55 black_hole6 阅读(237) 评论(0) 推荐(0) 编辑
摘要:某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路? Input测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数 阅读全文
posted @ 2018-11-09 23:44 black_hole6 阅读(162) 评论(0) 推荐(0) 编辑
摘要:import java.util.Scanner; public class hello { public static void main(String[] args) { System.out.println("hello world"); Scanner in = new Scanner(System.in); System.ou... 阅读全文
posted @ 2018-11-08 22:48 black_hole6 阅读(208) 评论(0) 推荐(0) 编辑
摘要:本人弱校小白一枚,希望可以在博客园和大佬们分享心得,和大佬有机会多多交流,交流QQ656484427 阅读全文
posted @ 2018-11-08 22:07 black_hole6 阅读(220) 评论(0) 推荐(0) 编辑
摘要:A 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. Wri 阅读全文
posted @ 2018-11-08 21:48 black_hole6 阅读(214) 评论(0) 推荐(0) 编辑
摘要:题目描述:A group of n schoolboys decided to ride bikes. As nobody of them has a bike, the boys need to rent them.The renting site offered ... 阅读全文
posted @ 2018-11-07 17:33 black_hole6 阅读(188) 评论(0) 推荐(0) 编辑
摘要:矩阵乘法(矩阵乘矩阵)在向量乘向量的运算中,是将每个元素与它对应的元素相乘,求所有乘积之和那么矩阵乘矩阵是不是就是两个同型矩阵的对应元素相乘呢?图样图森破两个矩阵相乘的前提是前一个矩阵的列数等于后一个矩阵的行数举个栗子,AAA为n∗kn*kn∗k矩阵,BBB为k∗mk... 阅读全文
posted @ 2018-11-06 15:27 black_hole6 阅读(264) 评论(0) 推荐(0) 编辑
摘要:约瑟夫是一个无聊的人!!!题目描述n个人(n#include#include#include#includeusing namespace std;queueq;int main(){ int n,m; cin>>n>>m; if(n==0&&m==0) { cou... 阅读全文
posted @ 2018-11-01 17:17 black_hole6 阅读(603) 评论(1) 推荐(0) 编辑

欢迎阅读『2018 年 11月 随笔档案』