ACM
文章平均质量分 93
记录练习ACM的过程,题目来自杭电HDOJ、POJ
Albert_Bolt
这个作者很懒,什么都没留下…
展开
-
POJ题目分类
POJ题目分类(转载)转载 2017-08-21 22:34:36 · 204 阅读 · 0 评论 -
1001 && 1002
ACM练习1001 Hello,World!题目如下:This is the first problem for test.Since all we know the ASCII code, your job is simple: Input numbers and output corresponding messages.InputThe input will c原创 2018-09-11 21:35:20 · 370 阅读 · 0 评论 -
输入外挂
输入外挂int input()//自己写输入函数 { char ch=' '; while(ch<'0'||ch>'9') { ch=getchar(); } int x=0; while(ch<='9'&&ch>='0') { x=x*10+ch-'0'; ...原创 2018-09-08 09:57:59 · 217 阅读 · 0 评论 -
ACM总结
Piggy-Bank(难度:1)Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Problem DescriptionBefore ACM can do anything, a budget must be prepared and the necessary financ...原创 2018-09-05 16:53:50 · 352 阅读 · 0 评论 -
杭电1002(两个大数加法)
A + B Problem IITime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Problem DescriptionI have a very simple problem for you. Given two integers A and B, your job is ...原创 2018-09-08 21:12:51 · 317 阅读 · 0 评论 -
杭电1042(大数阶乘)
N!Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Problem DescriptionGiven an integer N(0 ≤ N ≤ 10000), your task is to calculate N!InputOne N in one li...原创 2018-09-08 21:14:29 · 416 阅读 · 0 评论 -
POJ 1503(若干个大数相加)
Integer InquiryTime Limit: 1000MS Memory Limit: 10000KDescriptionOne of the first users of BIT’s new supercomputer was Chip Diller. He extended his exploration of powers of 3 to go from 0 t...原创 2018-09-08 21:17:55 · 239 阅读 · 0 评论 -
杭电1406(判断两个正整数之间完数的个数)
完数Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Problem Description完数的定义:如果一个大于1的正整数的所有因子之和等于它的本身,则称这个数是完数,比如6,28都是完数:6=1+2+3;28=1+2+4+7+14。本题的任务是判断两个正整数之间完数...原创 2018-07-31 22:39:23 · 1613 阅读 · 0 评论 -
并查集
并查集算法模板:不需要确定集合内元素个数int findroot(int x)//查找函数 { while(tree[x]!=x) x=tree[x]; return x; }void join(int x,int y)//合并函数 { int fx=findroot(x); int fy=findroot(y); if(fx!=fy) t...原创 2018-07-28 11:02:40 · 155 阅读 · 0 评论 -
杭电1116(并查集+欧拉路+欧拉回路)
Play on WordsTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Problem DescriptionSome of the secret doors contain a very interesting word puzzle. The team of arc...原创 2018-07-25 11:17:45 · 310 阅读 · 0 评论 -
杭电1213(并查集+让认识的人一桌)
How Many Tables(难度:1)Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Problem DescriptionToday is Ignatius’ birthday. He invites a lot of friends. Now it’s dinner...原创 2018-07-25 15:02:01 · 213 阅读 · 0 评论 -
杭电1232(并查集+修路让城镇连通)
畅通工程Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Problem Description某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接...原创 2018-07-25 15:16:53 · 228 阅读 · 0 评论 -
杭电1272(并查集+判断是否存在环形区域)
小希的迷宫(难度:1)Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Problem Description上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向...原创 2018-07-25 17:18:31 · 225 阅读 · 0 评论 -
杭电1325(并查集+判断是否为树)
Is It A Tree?(难度:2)Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Problem DescriptionA tree is a well-known data structure that is either empty (null, void, not...原创 2018-07-26 11:43:20 · 306 阅读 · 0 评论 -
杭电1381(hash或map分割子串个数)
Crazy SearchTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Problem DescriptionMany people like to solve hard puzzles some of which may lead them to madness. On...原创 2018-07-18 09:34:17 · 257 阅读 · 0 评论 -
杭电1496(hash求方程解)
EquationsTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Problem DescriptionConsider equations having the following form: a*x1^2+b*x2^2+c*x3^2+d*x4^2=0 a, b, ...原创 2018-07-18 15:28:51 · 344 阅读 · 0 评论 -
判断线段相交
判断线段相交模板:( 快速排斥+跨立 )#define maxn 1000001#define man 1e-12//点 struct point{ double x; double y;};//线段 struct line{ point a; point b;}lline[maxn];//判断线段是否相交 bool judge(li...原创 2018-07-28 10:43:20 · 234 阅读 · 0 评论 -
判断线段是否相交:快速排斥+跨立
矢量 如果一条线段的端点是有次序之分的话,那么这种线段就称为 有向线段,如果有向线段p1p2的起点p1在坐标的原点,则可以把它称为矢量p2矢量的加减 设二维矢量 P = (x1,...转载 2018-07-26 22:40:06 · 2474 阅读 · 0 评论 -
杭电1558(求线段相交+并查集求集合内个数)
Segment setTime Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Problem DescriptionA segment and all segments which are connected with it compose a segment set. The...原创 2018-07-26 22:32:35 · 292 阅读 · 2 评论 -
矩阵
矩阵乘法矩阵加法矩阵快速幂原创 2018-09-05 16:07:18 · 248 阅读 · 0 评论 -
杭电1575(矩阵快速幂+求矩阵k次幂的迹模9973的值)
Tr ATime Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Problem DescriptionA为一个方阵,则Tr A表示A的迹(就是主对角线上各项的和),现要求Tr(A^k)%9973。Input数据的第一行是一个T,表示有T组数据。 每组数据的第一行有n(2 ...原创 2018-08-16 10:51:31 · 703 阅读 · 0 评论 -
POJ3233(矩阵快速幂+求矩阵的1~k次幂的和模m+输出结果矩阵)
Matrix Power SeriesTime Limit: 3000MS Memory Limit: 131072KDescriptionGiven a n × n matrix A and a positive integer k, find the sum S = A + A2 + A3 + … + Ak.InputThe input contains exactly ...原创 2018-08-16 15:59:11 · 400 阅读 · 0 评论 -
背包问题
一、01背包题目有n件物品,容量为V的背包放入第 i 件物品耗费的费用是ci,得到的价值是wi求解将哪些物品装入背包可使价值总和最大特点每种物品仅有1件,可以选择放或不放。状态转移方程dp[j]表示背包内放入物品费用为 j 时的最大价值 dp[j] = max { dp[j], dp[ j - ci ] + wi }初始化要求恰好装满背包:dp[0]=0...原创 2018-09-05 11:39:20 · 172 阅读 · 0 评论 -
杭电2602(01背包)
Bone Collector(难度:1)Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Problem DescriptionMany years ago , in Teddy’s hometown there was a man who was called “Bone ...原创 2018-08-06 15:52:48 · 491 阅读 · 0 评论 -
杭电1114(完全背包)
Piggy-Bank(难度:1)Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Problem DescriptionBefore ACM can do anything, a budget must be prepared and the necessary fina...原创 2018-08-03 10:50:37 · 374 阅读 · 0 评论 -
杭电1059(多重背包)
Dividing(难度:1)Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Problem DescriptionMarsha and Bill own a collection of marbles. They want to split the collection a...原创 2018-08-06 11:38:59 · 240 阅读 · 0 评论 -
杭电2191(多重背包)
悼念512汶川大地震遇难同胞——珍惜现在,感恩生活Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Problem Description急!灾区的食物依然短缺! 为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市场有m种大...原创 2018-08-10 11:32:12 · 221 阅读 · 0 评论 -
动态规划的几个模板
错排公式dp[1]=0; dp[2]=1;for(int i=3;i<=20;i++){ dp[i]=(i-1)*dp[i-1]+(i-1)*dp[i-2];}cin>>n;cout<<dp[n]<<endl;最长递增子序列 LISfor(int i=1;i<=n;i++){ int tmax=1; ...原创 2018-09-05 15:57:20 · 547 阅读 · 0 评论 -
杭电1423(最长递增公共子序列 LICS)
Greatest Common Increasing SubsequenceTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Problem DescriptionThis is a problem from ZOJ 2432.To make it easyer,you ju...原创 2018-07-18 11:42:21 · 265 阅读 · 0 评论 -
杭电1003(最大子串和)
Max Sum(难度:1)Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Problem DescriptionGiven a sequence a[1],a[2],a[3]……a[n], your job is to calculate the max sum of a ...原创 2018-08-01 09:37:46 · 778 阅读 · 0 评论 -
杭电1025(最长上升子序列+二分查找优化)
Constructing Roads In JGShining’s Kingdom(难度:1)Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Problem DescriptionJGShining’s kingdom consists of 2n(n is no more...原创 2018-08-01 11:02:37 · 382 阅读 · 0 评论 -
杭电1087(和最大的递增子序列)
Super Jumping! Jumping! Jumping!(难度:1)Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Problem DescriptionNowadays, a kind of chess game called “Super Jumping! Ju...原创 2018-08-03 09:47:18 · 491 阅读 · 0 评论 -
杭电1058(输出第n个humble数)
Humble NumbersTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Problem DescriptionA number whose only prime factors are 2,3,5 or 7 is called a humble number. The ...原创 2018-08-01 14:57:25 · 245 阅读 · 0 评论 -
杭电1069(按长宽从大到小往上堆高塔)
Monkey and Banana(难度:1)Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Problem DescriptionA group of researchers are designing an experiment to test the IQ of a ...原创 2018-08-01 17:13:19 · 341 阅读 · 0 评论 -
杭电1078(仓鼠吃奶酪,DFS+动态规划)
FatMouse and CheeseTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Problem DescriptionFatMouse has stored some cheese in a city. The city can be considered as a ...原创 2018-08-02 21:05:46 · 1045 阅读 · 0 评论 -
杭电1158(公司雇人)
Employment Planning(难度:1)Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Problem DescriptionA project manager wants to determine the number of the workers needed...原创 2018-08-08 11:40:27 · 195 阅读 · 0 评论 -
状态压缩DP
讲解&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; 对问题的状态进行压缩,将状态转化为二进制的形式,通过位运算进行操作,要注意位运算符的优先级。使用在问题规模较小时使用。位运算对x取反:~x x+1(x为偶数):x|1 2x:1&amp;lt;...原创 2018-08-02 10:11:56 · 139 阅读 · 0 评论 -
杭电1074(交作业+状态压缩)
Doing Homework(难度:1)Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Problem DescriptionIgnatius has just come back school from the 30th ACM/ICPC. Now he has a lo...原创 2018-08-02 14:59:22 · 295 阅读 · 0 评论 -
斜率dp
斜率dp模型给定一个序列,分成若干段,分段有一定的限制条件,并需要一定的费用,问怎样分段才能在满足限制条件的情况下,使费用最小。条件状态转移方程类似于:dp[i] = dp[j] + (x[i] - x[j]) * (x[i] - x[j])。无法转化成dp[i] = f[j] + x[i]的形式。抽象将dp[i] = dp[j] + (x[i] - x[j])...原创 2018-08-14 11:46:54 · 264 阅读 · 0 评论 -
杭电3507(斜率dp)
Print ArticleTime Limit: 9000/3000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Problem DescriptionZero has an old printer that doesn’t work well sometimes. As it is antique, he s...原创 2018-08-14 14:46:03 · 265 阅读 · 0 评论