摘要:
主要利用JSP+Servlet实现验证码生成利用JQuery的ajax技术实现异步更换图片地址BufferedImage实现验证码图片的生成Servlet代码:package Register;import java.awt.Color;import java.awt.Font;import jav... 阅读全文
摘要:
主要实现的功能是点击完按钮以后,页面打印九九乘法表。使用的jquery的版本为1.10.2Insert title here点击显示 阅读全文
摘要:
原文地址:http://hi.baidu.com/xuhanqiu/item/99505e41aeef4eae61d7b916用qsort快两年的时候了,却一直没有真正弄懂cmp函数的返回值1,-1,0的函数. 今天在做凸包时,郁闷了....所以请教了snoopy,终于弄懂了cmp返回值的意识:int cmp(const void *a, const void *b)返回正数就是说 cmp 传入参数第一个要放在第二个后面, 负数就是传入参数第一个要放第二个前面, 如果是 0, 那就无所谓谁前谁后..下面就把snoopy曾经写的介绍qsort的完整版贴出来好了,我想有与我一样经历的朋友也可以弄懂 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=2202http://acm.hdu.edu.cn/showproblem.php?pid=3934在n个点中找出3个点,使得面积最大。这题用到的就是葛立恒扫描法。葛立恒扫描法是什么呢?现将现有的所有点进行排序,y从小到大。x从小到大。这样的话,我们可以得到什么呢?首先,y最小,x最小的一定是凸包点,这一点没有疑义吧。同理,x最大,y最大的也肯定是凸包点,我们所采用的步进法也将以这两个点作为开始。步进法分为两部分,我们姑且叫第一部分为左链,第二部分为右链。我们从左链开始,首先,取出0,1,2点。(至少需要3点才 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1086这道题真是让我彻底无解了,我是一开始直接算出2直线的向量,然后进行X乘,错误N次后,看了别人的博客,发现他们说什么判断点在直线2边,回头一看题目,才发现原来这题所说的是线段!线段的话,我们应该怎么判断是否相交呢?我们可以将一条线段a固定,然后判断另一条线段b的2端点在线段a的位置,如果一个在如果2点都同侧,那必定不相交。设线段端点为从A(x1[i],y1[i])到B(x2[i],y2[i]),线外一点P(x1[j],y1[j]),判断该点位于有向线A→B的那一侧。a=(x2[i]-x1[i],y2[i] 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=2161没有什么难度,不过要注意本题2不是素数。#include"stdio.h"#include"string.h"#include"stdlib.h"bool prime[16005];void IsPrime(){ int i,j,t; memset(prime,true,sizeof(prime)); prime[0]=prime[1]=false; prime[2]=false; prime[3]=true; for(i=4;i<=16 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=2098用筛法标记素数,这道题就简单了。不过有一点需要注意就是,要拆分成不同的素数,这就解释了为什么26这组数据输出2、#include"stdio.h"#include"string.h"#include"stdlib.h"bool prime[10005];void IsPrime(){ int i,j,t; memset(prime,true,sizeof(prime)); prime[0]=prime[1]=false; prime[2]=tr 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1431这道题,我也就特么错了27次而已!!主要用到筛法计算素数。27次错出不少经验:1.bool prime[];标记是否为素数时要用bool,别用int,bool只占一个字节,用int超内存。 2.先判断是否是回文,再判断是否是素数!否者超时。 3.由大神打表可知,10^7~10^8之间没有素数回文数,也就是说计算的时候只要算到10^7就可以了,也就是最大的回文素数就是9989899,所以数组只要开到这个数就够了。但是!即使最大回文是9989899,也要对比它... 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1527必败态和胜态有着如下性质:1、若面临末状态者为获胜则末状态为胜态否则末状态为必败态。2、一个局面是胜态的充要条件是该局面进行某种决策后会成为必败态。3、一个局面是必败态的充要条件是该局面无论进行何种决策均会成为胜态。有两堆石子,数量任意,可以不同。游戏开始由两个人轮流取石子。游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子;二是可以在两堆中同时取走相同数量的石子。最后把石子全部取完者为胜者。接下来就是寻找本题的必败态了,首先显然(0,0)就是一个,接着不急寻找下一个必败态,因为这个 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=2092x+y=n;x*y=m; 给定n,m,判断是否存在整数解.我一开始想到的是韦达定理, 假设x,y是一元二次方程的两解,则x+y=-b/a=n,x*y=c/a;而b^2-4ac等价于b^2/a^2-4c/a, 这样就能判断是否有解了, 可这题需要的是整数解.所以还需要一些步骤判断是否是整数x=-b+sqrt(b^2-4ac)/2a , 等价于 2x=n+sqrt(b^2-4ac)/a;等价于n+sqrt(b^2-4ac)为偶数,#include"stdio.h"#include&quo 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1405任何数都可以用若干个质数组成,这道题就是求一个数有哪些质数组成,其中相同的要用次方表示。负数时,结束程序。但是这道题有巨坑,就是格式。1,每个输出数字后面都有空格(每组输出最后有一个空格)2,两测试数据间有空行(最后一组数据后面没有空行)真是坑爹的格式啊啊啊啊!#include"stdio.h"#include"stdlib.h"#include"math.h"#include"string.h"int a[65540];i 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=2565本来是想做个大水,放松一下的,没想到这题好诡异,PE了不下3次,这题PE的主要原因不同其他题目,是隔行条件出错,是因为有些空格不要输出!!!!!#include"stdio.h"#include"stdlib.h"int main(){ int t,n,i,j,x; scanf("%d",&t); while(t--) { scanf("%d",&n); for(i=0;i0) printf("\n 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1723这道题呢讲的貌似是一个人让别人站一排传递信息,其中n代表一共有几个人,m代表一个人能传多远,问有从第一个传到最后一个一共有多少种传法。Hint4 1 : A->B->C->D4 2 : A->B->C->D, A->C->D, A->B->D从Hint中可以看出一个人可以在他传播距离内,传播给任意距离的人。本来这道题,我是没有什么思路,后来想想,这不就是[HDU]1208Pascal's Travels(http://www.cnblo 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1208起点在左上角,终点在右下角,而每一次走的步伐树只能等于该点的数值,值得注意的是0为死胡同。另外结果在2^63内,所以要用long long,还有= = ! 这道题地图每点的数值没有空格,所以不能%d直接输入,应该用字符型输入,再转化成整形。#include"stdio.h"#include"string.h"long long dp[50][50];int main(){ int n,i,j; int map[50][50]; char s[50][50]; wh 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1231跟Max Sum这题几乎一模一样,就是一个输出位置,一个输出位置的数值。 (http://www.cnblogs.com/sjy123/p/3239193.html)#include"stdio.h"#include"stdlib.h"int main(){ int t,n,i,news,old,begin,end,sum,x,tou,wei; while(scanf("%d",&n)&&n) { for(i=1;ine 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=2089这道题跟Bomb(http://www.cnblogs.com/sjy123/p/3247731.html)基本一样,不过多了一个不要包含4的条件,因为数值的范围不大,本来这道题完全可以暴力完成的,不过既然刚学了数位DP,就用一用吧。------------------------------------------------分割线-------------------------------------------------状态转移方程 dp[i][0]=dp[i-1][0]*9-dp[i-1][ 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=3555第一次做位数DP,卧槽,看了别人一晚上的代码,又调了一早上才做出来,艹艹艹!这道题讲的是,给定任意n,计算从1~n中有多少数包含连续的49.--------------------------------------分割线-----------------------------------------------------------这些是状态转移方程 dp[i][0]=dp[i-1][0]*10-dp[i-1][1]; //代表不含49 (当位数增加一位,不含49的数增加1... 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=2571这又是一题升级版的数塔.如果当前格子是(x,y),下一步可以是(x+1,y),(x,y+1)或者(x,y*k) 其中k>1,这句话是什么意思呢?举个例子从(1,1)到(1,4)可以按最规范的走法(1,1)(1,2)(1,3)(1,4);也可以(1,1)(1,2)(1,4);还可以(1,1)(1,4)这样的话,计算每个位置的最大值时,还要依次与该行步数y的分子比较;还有一个问题就是边界问题,(1,1)是很明显的边界,所以我避开了它.把这个二维方格矩阵分成了3部分,1是第一行,2是第一列,3是其余的各 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1176乍一看和塔数很像(http://www.cnblogs.com/sjy123/p/3241995.html),其实就是很像,一个升级版的塔数。-----------------------------------------------分割线-------------------------------------------------- 5 t=0 456 t=1 34567 t=2 2345678 ... 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1257第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度.我的思路是保存依次保存现在每个拦截系统能拦截的最高的高度,接下来输入的每一个高度,依次和这若干拦截系统的现在所能拦截的最高高度比较吗,若某次小于这个高度,就替代这个高度,若比这些拦截系统的高度都高,就重新创造一个拦截系统。#include"stdio.h"#include"stdlib.h"int a[100000],b[100000]; //a[]保存导弹高度,b[]保存每套系统的最高拦截高 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1728*代表墙, .代表路。问是否能从给定的一点走另一点。采取广度优先搜索。广度搜索从起点开始,依次搜索可以气扩展的每一个结点,当一层结点全部被搜索完后,再依次搜索第一个可扩展结点可以扩展的所有结点,直到找到或结点全被访问。#include"stdio.h"#include"stdlib.h"#include"string.h"int hash[110][110],k;int step[4][2]={{0,1},{1,0},{0,-1},{-1,0} 阅读全文
摘要:
T T 让我倍感丢人的一题!几行的代码,我乱七八糟的搞了好久。%x表示十六进制输入输出。。。。。#include"stdio.h"int main(){ int num1,num2,sum; while(scanf("%x%x",&num1,&num2)!=EOF) { sum=num1+num2; printf("%d\n",sum); }} 阅读全文
摘要:
计算A+B的和,不过要判断二个数的末尾几位数是否相同,若相同输出-1,不相同,输出A+B值。#include"stdio.h"#include"math.h"int main(){ int a,b,k,n,i; while(scanf("%d%d%d",&a,&b,&k)!=EOF) { if(a==0&&b==0) break; for(i=0,n=1;i<k;i++) n*=10; if(a%n==b%n) printf("-1\n"); else printf(& 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1012= =。 打表 ,快,准,狠!#include"stdio.h"int main(){ printf("n e\n"); printf("- -----------\n"); printf("0 1\n"); printf("1 2\n"); printf("2 2.5\n"); printf("3 2.666666667\n"); printf("4 2 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=3336题目大意讲一个字符串中,每一个子串出现的次数和(如abab,a出现2次,ab出现2次,aba出现1次,abab出现1次,共6次)KMP算法中next值为不为自身的最大首尾重复子串长度.所以可以建立足够大的数组,在相应next值长度的数组中记录下其出现的次数。最后累加起来就是所求的了。#include"stdio.h"#include"string.h"char t[200005];int next[200005],sum1[200005];void get_nex 阅读全文
摘要:
Problem C: Vito's familyBackgroundThe world-known gangster Vito Deadstone is moving to New York. He has a very big family there, all of them living in Lamafia Avenue. Since he will visit all his relatives very often, he is trying to find a house close to them.ProblemVito wants to minimize the to 阅读全文
摘要:
C: Optimal ParkingWhen shopping on Long Street, Michael usually parks his car at some random location, and then walks to the stores he needs. Can you help Michael choose a place to park which minimises the distance he needs to walk on his shopping round?<tex2html_verbatim_mark>Long Street is a 阅读全文
摘要:
Goldbach's Conjecture (II)Goldbach's Conjecture:For any even numberngreater than or equal to 4, there exists at least one pair of prime numbersp1andp2such thatn=p1+p2.This conjecture has not been proved nor refused yet. No one is sure whether this conjecture actually holds. However, one can 阅读全文
摘要:
Problem G: Simply EmirpAn integer greater than 1 is called a prime number if its only positive divisors (factors) are 1 and itself. Prime numbers have been studied over the years by a lot of mathematicians. Applications of prime numbers arise in Cryptography and Coding Theory among others.Have you t 阅读全文
摘要:
One-Two-ThreeYour little brother has just learnt to write one, two and three, in English. He has written a lot of those words in a paper, your task is to recognize them. Note that your little brother is only a child, so he may make small mistakes: for each word, there might be at most one wrong lett 阅读全文
摘要:
QueenThe ProblemThe game of Chess has several pieces with curious movements. One of them is theQueen, which can move any number of squares in any direction: in the same line, in the same column or in any of the diagonals, as illustrated by the figure below (black dots represent positions the queen m 阅读全文
摘要:
Problem IIs this the easiest problem?Time Limit : 1 second A triangle is a geometric shape with three positive sides. However, any given three sides won’t necessarily form a triangle. The three sides must form a closed region. Triangles are categorized depending on the values of the sides of a val.. 阅读全文
摘要:
Problem C: WERTYUA common typing error is to place the hands on the keyboard one row to the right of the correct position. So "Q" is typed as "W" and "J" is typed as "K" and so on. You are to decode a message typed in this manner.Input consists of several line 阅读全文
摘要:
Problem EAll in AllInput:standard inputOutput:standard outputTime Limit:2 secondsMemory Limit:32 MBYou have devised a new encryption technique which encodes a message by inserting between its characters randomly generated strings in a clever way. Because of pending patent issues we will not discuss 阅读全文
摘要:
Problem D: Beat the Spread!Superbowl Sunday is nearly here. In order to pass the time waiting for the half-time commercials and wardrobe malfunctions, the local hackers have organized a betting pool on the game. Members place their bets on the sum of the two final scores, or on the absolute differen 阅读全文
摘要:
Problem BPeter’s SmokesInput:standard inputOutput:standard outputTime Limit:4 secondsMemory Limit:32 MBPeter hasncigarettes. He smokes them one by one keeping all the butts. Out ofk> 1butts he can roll a new cigarette.How many cigarettes can Peter have?InputInput is a sequence of lines. Each line 阅读全文
摘要:
The DecoderWrite a complete program that will correctly decode a set of characters into a valid message. Your program should read a given file of a simple coded set of characters and print the exact message that the characters contain. The code key for this simple coding is a one for one character s 阅读全文
摘要:
Problem AHashmat the brave warriorInput:standard inputOutput:standard outputHashmat is a brave warrior who with his group of young soldiers moves from one place to another to fight against his opponents. Before fighting he just calculates one thing, the difference between his soldier number and the 阅读全文
摘要:
The 3n+ 1 problemBackgroundProblems in Computer Science are often classified as belonging to a certain class of problems (e.g., NP, Unsolvable, Recursive). In this problem you will be analyzing a property of an algorithm whose classification is not known for all possible inputs.The ProblemConsider t 阅读全文