hdoj 1564 Play a game】的更多相关文章

Play a game Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1805    Accepted Submission(s): 1445 Problem Description New Year is Coming! ailyanlu is very happy today! and he is playing a chessbo…
HDOJ 题目分类 //分类不是绝对的 //"*" 表示好题,需要多次回味 //"?"表示结论是正确的,但还停留在模块阶 段,需要理解,证明. //简单题看到就可以敲的 1000:    入门用: 1001:    用高斯求和公式要防溢出 1004:1012: 1013:    对9取余好了 1017:1021: 1027:    用STL中的next_permutation() 1029:1032:1037:1039:1040:1056:1064:1065: 10…
HDOJ 题目分类 /* * 一:简单题 */ 1000:    入门用:1001:    用高斯求和公式要防溢出1004:1012:1013:    对9取余好了1017:1021:1027:    用STL中的next_permutation()1029:1032:1037:1039:1040:1056:1064:1065:1076:    闰年 1084:1085:1089,1090,1091,1092,1093,1094, 1095, 1096:全是A+B1108:1157:1196:1…
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 56784    Accepted Submission(s): 19009 Problem Description FatMouse prepared M pounds of cat food, ready to trade with the cats g…
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3049    Accepted Submission(s): 2364 Problem Description You are the CEO of Nasty Hacks Inc., a company that creates small pieces of…
Box of Bricks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5994    Accepted Submission(s): 2599 Problem Description Little Bob likes playing with his box of bricks. He puts the bricks one up…
Problem Description Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges' favorite time is guessing the most popular problem. When the contest is over, they will count the balloons of each color…
卧槽....最近刷的cf上有最短路,本来想拿这题复习一下.... 题意就是在输出最短路的情况下,经过每个节点会增加税收,另外要字典序输出,注意a到b和b到a的权值不同 然后就是处理字典序的问题,当松弛时发现相同值的时候,判断两条路径的字典序 代码 #include "stdio.h" const int MAXN=110; const int INF=10000000; bool vis[MAXN]; int pre[MAXN]; int cost[MAXN][MAXN],lowcos…
Rectangles    HDOJ(2056) http://acm.hdu.edu.cn/showproblem.php?pid=2056 题目描述:给2条线段,分别构成2个矩形,求2个矩形相交面积. 算法:先用快速排斥判断2个矩形是否相交.若不相交,面积为0.若相交,将x坐标排序去中间2个值之差,y坐标也一样.最后将2个差相乘得到最后结果. 这题是我大一的时候做过的,当时一看觉得很水,写起来发现其实没我想的那么水.分了好几类情况没做出来.今天看了点关于判断线段相交的知识,想起了这题便拿来练…
链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1564 Description Input Output 只有一个数字,即你所能得到的整棵树的访问代价与额外修改代价之和的最小值. Sample Input 4 10 1 2 3 4 1 2 3 4 1 2 3 4 Sample Output 29 题解:我们还是老规矩设一个区间f[i][j][w]为区间i~j且树上的每个节点都大于等于w(因为子节点权值一定大于根节点,所以其实就是根节点要大于…
前言 不说话,先猛戳 Ranklist 看我排名. 这是用 node 自动刷题大概半天的 "战绩",本文就来为大家简单讲解下如何用 node 做一个 "自动AC机". 过程 先来扯扯 oj(online judge).计算机学院的同学应该对 ACM 都不会陌生,ACM 竞赛是拼算法以及数据结构的比赛,而 oj 正是练习 ACM 的 "场地".国内比较有名的 oj 有 poj.zoj 以及 hdoj 等等,这里我选了 hdoj (完全是因为本地上…
题意:有n个点,问其中某一对点的距离最小是多少 分析:分治法解决问题:先按照x坐标排序,求解(left, mid)和(mid+1, right)范围的最小值,然后类似区间合并,分离mid左右的点也求最小值 POJ 3714 #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> const int N = 1e5 + 5; const double INF = 1e…
题目传送门1 2 题意:从无序到有序移动的方案,即最后成1 2 3 4 5 6 7 8 0 分析:八数码经典问题.POJ是一次,HDOJ是多次.因为康托展开还不会,也写不了什么,HDOJ需要从最后的状态逆向搜索,这样才不会超时.判重康托展开,哈希也可. POJ //#include <bits/stdc++.h> #include<iostream> #include<algorithm> #include<string> #include<stack…
1.POJ 1564 Sum It Up 2.总结: 题意:在n个数里输出所有相加为t的情况. #include<iostream> #include<cstring> #include<cmath> #include<queue> #include<algorithm> #include<cstdio> #define F(i,a,b) for (int i=a;i<=b;i++) #define mes(a,b) memse…
HDOJ 1728 http://acm.hdu.edu.cn/showproblem.php?pid=1728 BFS求最少转过的弯 #include <stdio.h> #include <string.h> #include <queue> using namespace std; ][]; ][]; //记录到当前点已经转过个弯,初始化为-1,检测该点是否已遍历 struct node { int x; int y; }now,temp; ,,,-}; ,,-,…
并查集   英文:Disjoint Set,即“不相交集合” 将编号分别为1…N的N个对象划分为不相交集合, 在每个集合中,选择其中某个元素代表所在集合. 常见两种操作: n       合并两个集合 n       查找某元素属于哪个集合 并查集实现的程序代码: int set[MAXN],rank[MAXN]; //set[i]=k表示i的父节点是k,rank[]存储树的深度. int FindSet(int x) { if(set[x]!=x) set[x]=FindSet(set[x])…
Problem 1564 - A - Circle Problem's Link:   http://acm.whu.edu.cn/land/problem/detail?problem_id=1564 Mean: 给你一个长度不超过1e6的数字串,求第k大的环状数字串的前面那个位置. analyse: 好吧,我承认这是个水题,比赛的时候sb了,因为原来做过后缀自动机求解字符串的环状最小表示法,所以一直用后缀自动机的知识去套k小表示法,比赛的时候太固执了. 这题就是后缀数组的sa[]数组的运用,…
Fibonacci again and again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3610    Accepted Submission(s): 1491 Problem Description 任何一个大学生对菲波那契数列(Fibonacci numbers)应该都不会陌生,它是这样定义的:F(1)=1;F(2)=2;…
Problem Description Today is Ignatius' birthday. He invites a lot of friends. Now it's dinner time. Ignatius wants to know how many tables he needs at least. You have to notice that not all the friends know each other, and all the friends do not want…
题目传送门 /* 求逆序数的四种方法 */ /* 1. O(n^2) 暴力+递推 法:如果求出第一种情况的逆序列,其他的可以通过递推来搞出来,一开始是t[1],t[2],t[3]....t[N] 它的逆序列个数是N个,如果把t[1]放到t[N]后面,逆序列个数会减少t[1]个,相应会增加N-(t[1]+1)个 */ #include <cstdio> #include <cstring> #include <algorithm> using namespace std;…
题目传送门 题意:中文题面 分析:LCIS应用:设置b[]为a[]的反转,然后LCIS,若相等的是自己本身,则+1, 否则+2 代码: #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> using namespace std; const int MAXN = 2e2 + 10; const int INF = 0x3f3f3f3f; int a[MAX…
题目传送门 /* 题意:在一个矩阵里放炮台,满足行列最多只有一个炮台,除非有墙(X)相隔,问最多能放多少个炮台 搜索(DFS):数据小,4 * 4可以用DFS,从(0,0)开始出发,往(n-1,n-1)左下角走,x = cnt / n; y = cnt % n; 更新坐标, 直到所有点走完为止,因为从左边走到右边,只要判断当前点左上方是否满足条件就可以了 注意:当前点不能放炮台的情况也要考虑 g[x][y] == 'o'; 的错误半天才检查出来:) */ #include <cstdio> #…
题目传送门 /* 这题交给队友做,做了一个多小时,全排列,RE数组越界,赛后发现读题读错了,囧! 贪心:先确定最高位的数字,然后用贪心的方法,越高位数字越大 注意:1. Both A and B will have same number of digits 两个数字位数相同 2. which is no larger than 10^6 不是大小,而是长度不超过1e6 */ #include <cstdio> #include <iostream> #include <al…
题目传送门 /* 找规律/数位DP:我做的时候差一点做出来了,只是不知道最后的 is_one () http://www.cnblogs.com/crazyapple/p/3315436.html 数位DP:http://blog.csdn.net/libin56842/article/details/11580497 */ #include <cstdio> #include <iostream> #include <algorithm> #include <c…
题目传送门 /* 题意:给三个点求它们的外接圆,判断一个点是否在园内 计算几何:我用重心当圆心竟然AC了,数据真水:) 正解以后补充,http://www.cnblogs.com/kuangbin/archive/2013/09/11/3315055.html */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <string…
题目传送门 /* 水题:判断前后的差值是否为1,b[i]记录差值,若没有找到,则是第一个出错 */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <string> #include <cmath> using namespace std; ; const int INF = 0x3f3f3f3f; int a…
题目传送门 /* 水题:看见x是十的倍数就简单了 */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <string> #include <cmath> using namespace std; ; const int INF = 0x3f3f3f3f; int main(void) //HDOJ 4716…
题目传送门 /* 题意:处理完i问题后去处理j问题,要满足a[i][j] <= a[j][k],问最多能有多少问题可以解决 DFS简单题:以每次处理的问题作为过程(即行数),最多能解决n个问题,相同的问题(行数)不再考虑 详细解释:http://blog.csdn.net/libin56842/article/details/41909429 */ #include <cstdio> #include <iostream> #include <cstring> #…
题目连接 http://poj.org/problem?id=1564 Sum It Up Description Given a specified total t and a list of n integers, find all distinct sums using numbers from the list that add up to t. For example, if t = 4, n = 6, and the list is [4, 3, 2, 2, 1, 1], then…
DP/四边形不等式 裸题环形石子合并…… 拆环为链即可 //HDOJ 3506 #include<cmath> #include<vector> #include<cstdio> #include<cstring> #include<cstdlib> #include<iostream> #include<algorithm> #define rep(i,n) for(int i=0;i<n;++i) #define…