HDoj-1228-A + B】的更多相关文章

A + B 点我挑战题目 点我一起学习STL-MAP 题意分析 讲字符串和数字用map对应即可 代码总览 /* Title:HDOJ.1228 Author:pengwill Date:2016-11-21 */ #include <iostream> #include <map> #include <string> using namespace std; typedef map<string,int> mmp; mmp p; mmp::iterator…
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…
题目:codevs 1228 苹果树 链接:http://codevs.cn/problem/1228/ 看了这么多树链剖分的解释,几个小时后总算把树链剖分弄懂了. 树链剖分的功能:快速修改,查询树上的路径. 比如一颗树 首先,我们要把树剖分成树链.定义: fa[x]是x节点的上一层节点(就是他的爸爸). deep[x]是x节点的深度. num[x]是x节点下面的子节点的数量(包括自己) son[x]重儿子:一个节点的儿子的num[x]值最大的节点.其他的儿子都是轻儿子. 重链:重儿子连接在一起…
1228 苹果树  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond 题解  查看运行结果     题目描述 Description 在卡卡的房子外面,有一棵苹果树.每年的春天,树上总会结出很多的苹果.卡卡非常喜欢吃苹果,所以他一直都精心的呵护这棵苹果树.我们知道树是有很多分叉点的,苹果会长在枝条的分叉点上面,且不会有两个苹果结在一起.卡卡很想知道一个分叉点所代表的子树上所结的苹果的数目,以便研究苹果树哪些枝条的结果能力比较强. 卡卡所知道的是,每隔一些…
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个差相乘得到最后结果. 这题是我大一的时候做过的,当时一看觉得很水,写起来发现其实没我想的那么水.分了好几类情况没做出来.今天看了点关于判断线段相交的知识,想起了这题便拿来练…
前言 不说话,先猛戳 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…
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])…
稳定凸包问题 要求每条边上至少有三个点,且对凸包上点数为1,2时要特判 巨坑无比,调了很长时间= = //POJ 1228 //稳定凸包问题,等价于每条边上至少有三个点,但对m = 1(点)和m = 2(线段)要特判 //AC 2016-10-15 #include <cstdio> #include <cstdlib> #include <iostream> #include <cmath> #define MAXN 1010 double sqr(dou…
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=1228 随便看看就能发现,凸包上的每条边必须满足,有相邻的边和它斜率相同(即共线或凸包上每个点必须一定在三点共线上) 然后愉快敲完凸包+斜率判定,交上去wa了QAQ.原因是忘记特判一个地方....因为我们求的凸包是三点共线的凸包,在凸包算法中我们叉积判断只是>0而不是>=0,那么会有一种数据为所有点共线的情况,此时求出来的凸包上的点是>原来的点的(此时恰好符合答案NO,因为可以在这条线外随便点一个点就是一个凸包了...)然后特判一下.…
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1228 A + B Description 读入两个小于100的正整数A和B,计算A+B.需要注意的是:A和B的每一位数字由对应的英文单词给出. Input 测试输入包含若干测试用例,每个测试用例占一行,格式为"A + B =",相邻两字符串有一个空格间隔.当A和B同时为0时输入结束,相应的结果不要输出. Output 对每个测试用例输出1行,即A+B的值. Sample Input one…