随笔分类 -  hduoj

杭电
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4545这题太坑了,小明的串可以任意删掉某个字符 这句话不知道大家是怎么理解的,我觉得应该是能够删除其中的一种字符,但是个数不限。AC:直接模拟,相同或是能够转换得到就往后继续,不能就删除小明的,然后在判断。坑死了。。。。。。。祭恋 1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 #define MAX 1005 8 9 char ch[102][2];10 char ch1[MAX];11 char ch2[MA... 阅读全文
posted @ 2013-11-08 11:34 heity 阅读(232) 评论(0) 推荐(0)
摘要:题目链接 2013 ACM/ICPC Asia Regional Online —— Warmuphdu4706Children's Day就是循环使用a-z来输出一个反N 思路:直接模拟,采用一个数组来保存,数组中保存0-25的数字(字母出现的地方保存数字)(其他初始化为负数)输出时,直接输出数组中的数字+‘a’ 负数输出空格代码:#include #include int a[12][12];int main(){ /*freopen("1.txt","w",stdout);*/ int t = 0; int n = 3,i,j,k; for 阅读全文
posted @ 2013-09-10 16:00 heity 阅读(388) 评论(0) 推荐(0)
摘要:题目:http://acm.hdu.edu.cn/showproblem.php?pid=4493给你十二个月的工资,算平均数,保留两位,去除末尾的0使用暴力解决,嘻嘻,但是这题主要是在进位这个地方要处理好,由于要去除末尾0,采用一个数组来保存小数点后面的数,当要进位时,从未到头查看是否是要进位最后将整数部分输出,然后输出小数部分(满足要求的小数位输出)代码:#include int main(){ double x,sum; int t,i,j; scanf("%d",&t); while(t--) { i = 12; sum = 0... 阅读全文
posted @ 2013-08-25 21:26 heity 阅读(292) 评论(0) 推荐(0)
摘要:题目:http://ac.jobdu.com/problem.php?pid=1481http://acm.nyist.net/JudgeOnline/problem.php?pid=129http://poj.org/problem?id=1308http://acm.hdu.edu.cn/showproblem.php?pid=1272题目意思就是判断一些给定的支点构成的树是不是一颗合法的树,判断是不是一颗合法的树如下: 1、该树只有一个根节点 2、不存在环对于上述两种情况采用如下进行判断: 1、定义一个标识符,当这个点出现,并且父节点和自己相同的... 阅读全文
posted @ 2013-08-25 11:13 heity 阅读(258) 评论(0) 推荐(0)
摘要:题目: http://acm.hdu.edu.cn/showproblem.php?pid=2565这个题很简单但是很容易错,写来给自己一个警示把首先在最后一个x后面没有空格,然后就是那个换行一直换就好,我一开始是空格后来是那个换行出问题,,纠结了半天,,,,#include #include int a[80][80];int main(){ /** freopen("1.txt","w",stdout);*/ int t; int x1,y1,x2,y2,i,j; scanf("%d",&t); while(t--) { 阅读全文
posted @ 2013-08-22 21:06 heity 阅读(374) 评论(0) 推荐(0)
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2571简单dp,dp[n][m] +=( dp[n-1][m],dp[n][m-1],d[i][k] )k为m的因子PS:0边界要初始为负数(例如-123456789)越大越好代码:#include #include int dp[25][1005];#define max(x,y) x > y ? x : yint main(){ int T; scanf("%d",&T); while(T--) { memset(dp,0,sizeof(dp)); ... 阅读全文
posted @ 2013-07-26 17:34 heity 阅读(217) 评论(0) 推荐(0)
摘要:FatMouse' TradeTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 31290Accepted Submission(s): 10104Problem DescriptionFatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBe 阅读全文
posted @ 2013-05-02 18:47 heity 阅读(254) 评论(0) 推荐(0)
摘要:最少拦截系统Time Limit : 2000/1000ms (Java/Other)Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 10Accepted Submission(s) : 3Font: Times New Roman | Verdana | GeorgiaFont Size: ← →Problem Description 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不 能超过前一发的高度.某天,雷达捕捉到敌 阅读全文
posted @ 2013-04-26 08:42 heity 阅读(102) 评论(0) 推荐(0)
摘要:(1) n条直线最多分平面问题题目大致如:n条直线,最多可以把平面分为多少个区域。析:可能你以前就见过这题目,这充其量是一道初中的思考题。但一个类型的题目还是从简单的入手,才容易发现规律。当有n-1条直线时,平面最多被分成了f(n-1)个区域。则第n条直线要是切成的区域数最多,就必须与每条直线相交且不能有同一交点。 这样就会得到n-1个交点。这些交点将第n条直线分为2条射线和n-2条线断。而每条射线和线断将以有的区域一分为二。这样就多出了2+(n-2)个区域。故:f(n)=f(n-1)+n=f(n-2)+(n-1)+n……=f(1)+1+2+……+n=n(n+1)/2+1(2) 折线分平面(h 阅读全文
posted @ 2013-04-25 15:17 heity 阅读(106) 评论(0) 推荐(0)
摘要:三角形Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3416Accepted Submission(s): 2368Problem Description用N个三角形最多可以把平面分成几个区域?Input输入数据的第一行是一个正整数T(1<=T<=10000),表示测试数据的数量.然后是T组测试数据,每组测试数据只包含一个正整数N(1<=N<=10000).Output对于每组测试数据,请输出题目中要求的结果.Samp 阅读全文
posted @ 2013-04-23 12:09 heity 阅读(125) 评论(0) 推荐(0)
摘要:汉诺塔问题,给你四个柱子,要把所有的盘子从1 移到 3 上1------12 -----33 ------54-------95 -------136--------177 -------25要是按着先把n-3个盘子移到另一个柱子上这样就有一个递推公式,f[n] = 2[n - 3] + 2 ^3-1用12带进去发现不对,不知道为什么,后来yy了一下,能够找出关系,希望大牛指点。。。。 1 #include <stdio.h> 2 #include <string.h> 3 #include <math.h> 4 5 long long a[65]; 6 7 阅读全文
posted @ 2013-04-23 11:35 heity 阅读(161) 评论(0) 推荐(0)
摘要:Problem DescriptionIn how many ways can you tile a 3xn rectangle with 2x1 dominoes? Here is a sample tiling of a 3x12 rectangle.InputInput consists of several test cases followed by a line containing -1. Each test case is a line containing an integer 0 ≤ n ≤ 30. OutputFor each test case, output one 阅读全文
posted @ 2013-04-23 08:54 heity 阅读(194) 评论(0) 推荐(0)
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1023该题就是求卡特兰数,只是处理的时候要用大数来处理,使用递推公式:h(n)=C(2n,n)/(n+1) (n=0,1,2,...)= A(2n,n)/(n+1)!改写我先求A(2n,n)然后除以(n+1)! 1 #include <cstdio> 2 #include <iostream> 3 #include <cstring> 4 5 using namespace std; 6 7 #define N 250 8 int a[N]; 9 10 void 阅读全文
posted @ 2013-04-22 16:09 heity 阅读(181) 评论(0) 推荐(0)
摘要:Train Problem ITime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 14413Accepted Submission(s): 5310Problem DescriptionAs the new term comes, the Ignatius Train Station is very busy nowadays. A lot of student want to get back to school by train(because 阅读全文
posted @ 2013-04-22 15:15 heity 阅读(137) 评论(0) 推荐(0)
摘要:Buy the TicketTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3246Accepted Submission(s): 1350Problem DescriptionThe "Harry Potter and the Goblet of Fire" will be on show in the next few days. As a crazy fan of Harry Potter, you will go t 阅读全文
posted @ 2013-04-22 13:38 heity 阅读(142) 评论(0) 推荐(0)
摘要:一开始想的时候吧那个搞错了,那个在同一层的时候对停留5S 1 #include <stdio.h> 2 #include <string.h> 3 4 int a[3005]; 5 6 int main() 7 { 8 int n; 9 while(scanf("%d",&n) && n)10 {11 int i;12 long sum = 0;13 memset(a,0,sizeof(a));14 for(i = 1; i <= n; i++)15 scanf("%d",&a... 阅读全文
posted @ 2013-04-22 10:26 heity 阅读(117) 评论(0) 推荐(0)
摘要:判断一个长方体和一个球是否相交找到一个离求最近的点,然后算这个点到这个球圆心的距离,就能判断出是否相交代码: 1 #include <cstdio> 2 #include <cmath> 3 #include <iostream> 4 5 using namespace std; 6 7 typedef struct point 8 { 9 double x,y,z;10 }point;11 12 point a[10];13 14 double judge(double x,double y,double z,point q)15 {16 double s 阅读全文
posted @ 2013-04-10 08:14 heity 阅读(192) 评论(0) 推荐(0)
摘要:Problem DescriptionCrixalis - Sand King used to be a giant scorpion(蝎子) in the deserts of Kalimdor. Though he's a guardian of Lich King now, he keeps the living habit of a scorpion like living underground and digging holes.Someday Crixalis decides to move to another nice place and build a new ho 阅读全文
posted @ 2013-04-07 10:31 heity 阅读(196) 评论(0) 推荐(0)
摘要:Different DivisionTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 165Accepted Submission(s): 75Problem DescriptionNow we will give you a graph, there are many points in the graph. We will choose two different points arbitrarily, and connect them as 阅读全文
posted @ 2013-04-06 17:57 heity 阅读(201) 评论(0) 推荐(0)
摘要:A + B Problem IITime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 150756Accepted Submission(s): 28485Problem DescriptionI have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.InputThe first line of 阅读全文
posted @ 2013-04-03 14:43 heity 阅读(164) 评论(0) 推荐(0)