算法
文章平均质量分 87
反向爆零直至AK
从零开始的编程生活,枯燥却紧张
展开
-
最大岛屿---深搜(记录个数)
题目:点击打开链接;#include#include#includeusing namespace std;int man,m,n,t,is_shu,e;int go[8][2]= {{0,1},{0,-1},{1,0},{-1,0},{1,1},{-1,-1},{-1,1},{1,-1}};int map[509][509];int sum;void gg(int x,原创 2016-12-12 10:23:03 · 331 阅读 · 0 评论 -
素数
素数距离问题时间限制:3000 ms | 内存限制:65535 KB难度:2描述现在给出你一些数,要求你写出一个程序,输出这些整数相邻最近的素数,并输出其相距长度。如果左右有等距离长度素数,则输出左侧的值及相应距离。如果输入的整数本身就是素数,则输出该素数本身,距离输出0输入第一行给出测试数据组数N(0接下来的N行每行有一个整数M(0输出原创 2016-11-04 09:59:09 · 217 阅读 · 0 评论 -
素数打表
孪生素数问题时间限制:3000 ms | 内存限制:65535 KB难度:3描述写一个程序,找出给出素数范围内的所有孪生素数的组数。一般来说,孪生素数就是指两个素数距离为2,近的不能再近的相邻素数。有些童鞋一看到题就开始写程序,不仔细看题,咱们为了遏制一下读题不认真仔细的童鞋,规定,两个素数相邻为1的也成为孪生素数。输入第一行给出N(0接下来组测原创 2016-11-03 21:41:40 · 321 阅读 · 1 评论 -
筛法打表
筛选素数int a[n]= {0};//将所有的数都定为零,n为有n个数; a[1]=1; for(i=2; i { if(a[i]==0) for(j=2*i; j a[j]=1;//将不是素数的标为1; }原创 2016-10-26 22:00:26 · 291 阅读 · 0 评论 -
部分和问题(入门题)(c++与c)(简单搜索)
部分和问题(入门题)时间限制:1000 ms | 内存限制:65535 KB难度:0描述给你n个数(a1,a2,a3.......an) ,是否存在某一些数字加起来等于k,有就输出 "YES",否则输出 "NO"。数据范围:na1+a2+....an在int范围里面.输入多组输入每组第一行输入两个数n,k第二行输入n个原创 2016-12-02 17:03:46 · 1000 阅读 · 0 评论 -
最少步数(简单广搜)
A. 最少步数Time Limit: 3000msMemory Limit: 128000KB64-bit integer IO format: Java class name:Submit Status这有一个迷宫,有0~8行和0~8列: 1,1,1,1,1,1,1,1,1 1,0,0,1,0,0,1,0,1 1,0,0,1,转载 2016-12-10 17:28:55 · 633 阅读 · 0 评论 -
二分
#include#include#includeusing namespace std;int a[1000005],b[100005];int main(){ int m,n,i,j,left,right,mid,flag; scanf("%d%d",&m,&n); for(j=0; j for(i=0; i sort(a原创 2016-11-21 14:37:01 · 280 阅读 · 0 评论 -
图形的搜索
A. 水池数目Time Limit: 3000msMemory Limit: 128000KB64-bit integer IO format: Java class name:Submit Status PID: 4639南阳理工学院校园里有一些小河和一些湖泊,现在,我们把它们通一看成水池,假设有一张我们学校的某处的地图,这个地图上仅原创 2016-12-09 11:22:20 · 341 阅读 · 0 评论 -
广搜记录路径
点击打开链接#include#include#include#include#define MAX 1005using namespace std;int Map[MAX][MAX],n,v[4][2]= {{0,1},{0,-1},{1,0},{-1,0}};struct node{ int x,y,step;};node ans[MAX][MAX];void原创 2016-12-22 21:27:50 · 1660 阅读 · 0 评论 -
(三维广搜)3Ddungeon
3Ddungeon时间限制: 1000ms内存限制: 128000KB64位整型: Java 类名:上一题 提交 运行结果 统计 讨论版 下一题类型: 没有 没有 难度 lv.1 lv.2 lv.3 lv.4 lv.5原创 2016-12-23 20:27:36 · 234 阅读 · 0 评论 -
L - A Knight's Journey(好麻烦)
L - A Knight's Journey注意:1.必须按照字典序走法;点击打开链接2.横纵坐标不能超过8;3.输出时字母代表列,数字代表行;第一种#include#includestruct node{ int x,y;} c[30][30];int a,b,sum,flag,g;int xia[30][3原创 2017-01-07 11:27:15 · 220 阅读 · 0 评论 -
滑雪(深搜与动归)
P - 滑雪Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道载一个区域中最长底滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。下面是一个例子 1 2 3 4 516 17 18 19 615 24 25 20 714 23原创 2017-01-07 20:51:39 · 377 阅读 · 0 评论 -
F - Nightmare (目前只会广搜)
F - NightmareIgnatius 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 the labyrinth before the bomb exp原创 2017-01-08 14:24:58 · 217 阅读 · 0 评论 -
G - 诡异的楼梯 (bfs)
G - 诡异的楼梯Hogwarts正式开学以后,Harry发现在Hogwarts里,某些楼梯并不是静止不动的,相反,他们每隔一分钟就变动一次方向.比如下面的例子里,一开始楼梯在竖直方向,一分钟以后它移动到了水平方向,再过一分钟它又回到了竖直方向.Harry发现对他来说很难找到能使得他最快到达目的地的路线,这时Ron(Harry最好的朋友)告诉Harry正好有一个魔法道具可以帮助他寻原创 2017-01-09 12:52:34 · 202 阅读 · 0 评论 -
M - Children of the Candy Corn (第一次写左右优先的搜索,自己独立写的可能不够优化)
M - Children of the Candy CornThe cornfield maze is a popular Halloween treat. Visitors are shown the entrance and must wander through the maze facing zombies, chainsaw-wielding psychopaths, hippi原创 2017-01-09 18:38:44 · 260 阅读 · 0 评论 -
Common Subsequence (dp)
Common SubsequenceA subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = another sequence Z = is a subsequence of X if there exis原创 2017-01-11 10:23:08 · 218 阅读 · 0 评论 -
2350: 彩排(二进制记录个数)
题目链接:http://acm.nyist.me/JudgeOnline/problem.php?id=23502350: 彩排时间限制: 1 Sec 内存限制: 128 MB提交: 142 解决: 16[提交][状态][讨论版]题目描述南阳理工学院,举办运动会,有N个人来自不同的学院,在站队伍的时候每一排需要站K个人,并且这一排的人需要来自同一个学院,但是现在其中有一个学院的人数不是原创 2017-07-29 14:47:53 · 241 阅读 · 0 评论 -
拓扑排序
拓扑排序也是排序的一种。 例如, 1 2 //2在1前 1 3 //3在1前 3 2 //2在3前 2 4 //4在2前 输出 满足上面要求的排列方式 1 3 2 4 拓扑排序的使用条件:有前后的位置要求(例如,2在1前面,或者,先有2,再有1)【拓扑排序】例题:逃生 链接:htt原创 2017-07-21 16:20:28 · 308 阅读 · 0 评论 -
POJ 2528 Mayor's posters (线段树+离散化)
Mayor’s posters 题目链接:传送门DescriptionThe citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral posters at all places at their原创 2017-08-09 08:49:41 · 277 阅读 · 0 评论 -
hdu 6045 Is Derek lying?
题目链接:传送门Is Derek lying?Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1606 Accepted Submission(s): 830Problem Description Derek and Alfia原创 2017-08-17 08:46:43 · 250 阅读 · 0 评论 -
hdu 6034 Balala Power!
题目链接:传送门Balala Power! Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 5833 Accepted Submission(s): 1475Problem DescriptionTalented Mr.T原创 2017-08-16 18:37:54 · 207 阅读 · 0 评论 -
hdu 6033 Add More Zero
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6033这一题题目很简单,但是当时就是想了很久,没有想到。求n个数相(a1–an)乘后,所得数的位数:log10(ai)的和就为长度。以前做过 数的长度这道题,但是当时没有想太多,这回是,知道了。#include<stdio.h>#include<math.h>int main(){ int原创 2017-08-16 08:56:25 · 240 阅读 · 0 评论 -
hdu 6047 Maximum Sequence
2017 Multi-University Training Contest - Team 2 链接:传送门Maximum SequenceTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 932 Accepted Submiss原创 2017-07-28 15:08:00 · 185 阅读 · 0 评论 -
最长递增子序列 O(NlogN)算法
最长递增子序列 O(NlogN)算法今天回顾WOJ1398,发现了这个当时没有理解透彻的算法。 看了好久好久,现在终于想明白了。 试着把它写下来,让自己更明白。最长递增子序列,Longest Increasing Subsequence 下面我们简记为 LIS。 排序+LCS算法 以及 DP算法就忽略了,这两个太容易理解了。假设存在一个序列d[1..9] = 2 1 5 3 6 4 8 9 7转载 2017-07-24 10:43:06 · 862 阅读 · 0 评论 -
最大和问题(一维数组和二维数组)(dp问题)
dp问题一直是比较头疼的问题,现在介绍两个较为相似的问题;1 .一维的最大和问题:Max Sum HDU - 10032.二维的最大和问题:题目1139:最大子矩阵【一维最大和】以样例讲:给你n个整数,问连续的几个数的和最大是多少?(即最大字串是多少) 该题有几个要求: (1)要求和相同时,取最开始的; (2)须输出起始位置; 输入 0 6原创 2017-07-13 18:08:53 · 775 阅读 · 0 评论 -
zoj 2836 Number Puzzle(容斥原理)
题目链接:传送门Number Puzzle Time Limit: 2 Seconds Memory Limit: 65536 KB Given a list of integers (A1, A2, …, An), and a positive integer M, please find the number of positive integers that are not gr原创 2017-08-18 10:05:00 · 274 阅读 · 0 评论 -
hdu 1255 覆盖的面积 (线段树,离散化+扫描线)
题目链接:传送门覆盖的面积Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6058 Accepted Submission(s): 3051Problem Description 给定平面上若干矩形,求出被这些矩形覆盖过至少两次原创 2017-08-11 10:31:58 · 230 阅读 · 0 评论 -
hdu 1542 Atlantis (线段树,离散化+扫描线)
Atlantis 题目链接:传送门AtlantisTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 13741 Accepted Submission(s): 5704Problem DescriptionThere are se原创 2017-08-09 17:35:16 · 305 阅读 · 0 评论 -
hdu 3265 Posters (线段树,离散化+扫描线)
题目链接:传送门PostersTime Limit: 5000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6379 Accepted Submission(s): 1537Problem DescriptionTed has a new house with原创 2017-08-11 17:29:26 · 237 阅读 · 0 评论 -
zoj-3687-The Review Plan I(禁位排序)
题目链接:传送门The Review Plan I Time Limit: 5 Seconds Memory Limit: 65536 KB Michael takes the Discrete Mathematics course in this semester. Now it’s close to the final exam, and he wants to take a co原创 2017-08-18 17:43:07 · 309 阅读 · 0 评论 -
B - I Hate It (线段树,点的更新+区间最大值)
B - I Hate It 链接:传送门很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。 这让很多学生很反感。 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。Input本题目包含多组测试,请处理到文件结束。 在每个测试的第一行,有两个正整数 N 和 M ( 0<N<=200000,0原创 2017-08-04 21:01:27 · 174 阅读 · 0 评论 -
A Simple Problem with Integers (线段树,区间求和+区间更新)
A Simple Problem with Integers 链接:传送门You have NN integers, A1,A2,⋯,ANA1,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 giv原创 2017-08-04 21:22:14 · 230 阅读 · 0 评论 -
Count the Colors (线段树,区间更新)
Count the Colors 链接:传送门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原创 2017-08-04 21:51:58 · 169 阅读 · 0 评论 -
楼房重建 (线段树)
题目链接:传送门 2957: 楼房重建Time Limit: 10 Sec Memory Limit: 256 MB Submit: 2289 Solved: 1081 [Submit][Status][Discuss] Description 小A的楼房外有一大片施工工地,工地上有N栋待建的楼房。每天,这片工地上的房子拆了又建、建了又拆。他经常无聊地看着窗外发呆,数自己能够看到多少栋原创 2017-08-12 18:44:40 · 551 阅读 · 0 评论 -
hdu 6154 CaoHaha's staff(找规律)
题目链接:传送门CaoHaha’s staffTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 0 Accepted Submission(s): 0Problem Description “You shall not pass!”原创 2017-08-19 17:44:42 · 384 阅读 · 0 评论 -
Can you answer these queries?(线段树,区间更新,更新到点)
题目 链接:传送门A lot of battleships of evil are arranged in a line before the battle. Our commander decides to use our secret weapon to eliminate the battleships. Each of the battleships can be marked a valu原创 2017-08-05 16:59:30 · 211 阅读 · 0 评论 -
hdu 6092 Rikka with Subset(多重背包)
题目链接:这里写链接内容Rikka with SubsetTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1647 Accepted Submission(s): 822Problem Description As we know原创 2017-08-17 18:12:09 · 213 阅读 · 0 评论 -
hdu 6165 FFF at Valentine (Tarjan算法,scc+dp)
题目链接:传送门第一次遇到Tarjan算法的题。 Tarjan算法讲解:传送门 引用的链接:传送门【强连通分量】有向图中, u可达v不一定意味着v可达u. 相互可达则属于同一个强连通分量(Strongly Connected Component, SCC)有向图和它的转置的强连通分量相同 所有SCC构成一个DAG 1、强连通图。在一个强连通图中,任意两个点都通过一定路径互相连通。比如图一是一原创 2017-08-23 17:48:52 · 353 阅读 · 0 评论 -
hdu 6180 Schedule(贪心)
题目链接:传送门ScheduleTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 153428/153428 K (Java/Others) Total Submission(s): 1111 Accepted Submission(s): 449Problem Description There are N schedules原创 2017-09-05 18:37:56 · 283 阅读 · 0 评论 -
对拍程序--C语言
对拍有3步: 1.生成数据,想要生成什么数据要根据题目立定 2.建立你的数据的输出和正确代码的输出 3.建立对拍程序首先是生成数据:#include<stdio.h>#include<time.h>//保证每次生成的数据都不同#include<stdlib.h>int a[109];int main(){ freopen("date.txt","w",stdout);//将生原创 2017-09-13 22:39:03 · 1236 阅读 · 0 评论