hdoj
文章平均质量分 53
__Vincent__
我不去想是否能够成功既然选择了远方便只顾风雨兼程
展开
-
【HDOJ】1708 -> Fibonacci String
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1708心得: 用map统计相同字符出现的次数比较方便,另外此题格式不严谨,最后多了一行回车,考虑到你就PE了。代码:#include #include using namespace std;int main(){ int t,i,k; __int原创 2013-08-20 11:23:14 · 693 阅读 · 0 评论 -
【HDOJ】1164 -> Eddy's research I
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1164心得: 做一个2~n的循环,取出i,筛掉i的倍数,当n不包含因子i的时候i++。代码:#includeusing namespace std;int main(){ int n,i,j,a[100]; while(cin>>n){ for(原创 2013-08-16 11:54:10 · 511 阅读 · 0 评论 -
【HDOJ】1196 -> Lowest Bit
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1196心得: itoa(int value, char *string, int radix)对于进制转换非常管用,参见http://baike.baidu.com/view/982195.htm代码:#include #include using原创 2013-08-16 12:45:55 · 555 阅读 · 0 评论 -
【HDOJ】1235 -> 统计同成绩学生人数
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1235心得: 个人觉得这题用multiset解代码最简洁,若果有更简洁的,交流交流哈。代码:#include #include using namespace std;int main(){ int n,x; multiset ms; while原创 2013-08-16 21:59:54 · 463 阅读 · 0 评论 -
【HDOJ】1234 -> 开门人和关门人
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1234心得: 时间换算成秒比较大小,使用结构体,memcpy内存拷贝。代码:#include using namespace std;typedef struct {char ID[20];int s0;int s1;} Data;int main()原创 2013-08-16 21:45:16 · 689 阅读 · 0 评论 -
【HDOJ】1236 -> 排名
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1236心得: 被WA四次的题,主要难点在于比较函数的写法上。如果成绩不同则按成绩降序排,成绩相同则按学号升序排。代码:#include #include using namespace std;typedef struct{char ID[21];in原创 2013-08-17 09:07:54 · 867 阅读 · 0 评论 -
【HDIJ】1266 -> Reverse Number
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1266心得: 人人都会做的题,贴个简单点代码,用reverse反转字符串,find_last_not_of('0')返回字符串第一个不是0的位置。代码:#include #include #include using namespace std;in原创 2013-08-17 16:31:07 · 780 阅读 · 0 评论 -
【HDOJ】1205 -> 吃糖果
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1205心得: 代码本身没有难度,只要能够想出sum-max>=max-1本题就不难了。因为其他糖果都能插进最多的糖果的缝隙中,要把最多的糖果分隔开,最少需要max-1个其他糖果。另外,测试数据过多时尽量采用scanf函数。代码:#include int m原创 2013-08-16 19:46:46 · 679 阅读 · 0 评论 -
【HDOJ】1058 -> Humble Numbers
心得: DP问题,a[i]=min{ a[j]*2 , a[k]*3 , a[m]*5 , a[n]*7 }。如果认为本题的重点是打表的话你就错了,英语序数词坑了无数人,所以下面我就不厌其烦把小学英语知识点再回顾一遍。末位是1但后两位不是11的+st末位是2但后两位不是12的+nd末位是3但后两位不是13的+rd代码:#in原创 2013-08-14 23:29:45 · 569 阅读 · 0 评论 -
【HDOJ】1335 -> Basically Speaking
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1335心得: 先将原数转为十进制数,再利用itoa函数或strtol函数转化为其他进制数。注意,itoa转化后的字符为小写,可以用toupper函数将小写转化为大写。代码:#include #include #include using namespa原创 2013-08-18 10:56:59 · 674 阅读 · 0 评论 -
【HDOJ】1395 -> 2^x mod n = 1
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1395心得: 欧拉定理: a^phi(m) ≡1(mod m),phi(m)为欧拉函数,表示比m小且与m互质的正整数个数,当m为质数时,phi(m)=m-1。即为费马定理。本题中:1、当n为1时无解。 2、当n为偶数时,2^x也为偶数,所以2^x不可能和n关于奇数1同原创 2013-08-18 21:33:56 · 771 阅读 · 0 评论 -
【HDOJ】1405 -> The Last Practice
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1405心得: 题目输出格式有问题,每行最后一个数多输出了一个空格。代码:#include #include int main(){ int n,i,j,a[20][2],t=1; while(~scanf("%d",&n) && n>0){原创 2013-08-18 23:34:22 · 752 阅读 · 0 评论 -
【HDOJ】2034 -> 人见人爱A-B
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2034#include #include #include #include using namespace std;int main(){ int m,n,x; set s; while(cin>>m>>n,m||n){ s.clear(); while(m--){原创 2014-01-18 14:23:37 · 776 阅读 · 0 评论 -
【HDOJ】1106 -> 排序
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1106心得: sscanf函数可以从字符串格式化写入相符类型的数据,功能十分强大。参见http://baike.baidu.com/view/1364018.htm代码:#include #include #include using namespac原创 2013-08-15 23:16:27 · 887 阅读 · 0 评论 -
【HDOJ】1201 -> 18岁生日
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1201心得: 每年当做365天,每过一次闰年2月29日(出生时不包括,18岁生日时包括)总天数就+1。代码:#include using namespace std;const int NUM_OF_BIRTHDAY=18;bool LeepYear(原创 2013-08-16 15:49:20 · 660 阅读 · 0 评论 -
【HDOJ】1197 -> Specialized Four-Digit Numbers
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1197心得: 利用映射表转换字符。代码:#include #include using namespace std;int main(){ char base10[20],base12[20],base16[20]; int i,j,sum10,s原创 2013-08-16 14:34:15 · 665 阅读 · 0 评论 -
【HDOJ】1862 -> EXCEL排序
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1862心得: 用sort比较函数对结构体进行排序。代码:#include #include using namespace std;typedef struct {char ID[7]; char Name[9]; short Score;}STUDE原创 2013-08-20 14:50:02 · 594 阅读 · 0 评论 -
【HDOJ】1048 -> The Hardest Problem Ever
心得: 可以用映射表,也通过两个字符数组相互替换。(以下代码采用后者方法)代码:#include using namespace std;int main(){ char s1[30]="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; char s2[30]="VWXYZABCDEFGHIJKLMNOPQRSTU"; char c[1000]原创 2013-08-14 12:54:00 · 628 阅读 · 0 评论 -
【HDOJ】1032 -> The 3n + 1 problem
心得: 输入范围【a,b】注意判断是否满足b>=a,返回值也要保证a在b前。代码:#include using namespace std; int f(int n){ int sum=1; while(n!=1){ if(n%2==1) n=3*n+1; else n/=2; sum++; } return sum;}原创 2013-08-13 22:01:26 · 585 阅读 · 0 评论 -
【HDOJ】1029 -> Ignatius and the Princess IV
心得: 通常可以用a[index]=k表示数字index重复的次数为k。代码:#include using namespace std; const int MAX=500000;int a[MAX];int main(){ int n,x,i,id; while(cin>>n){ memset(a,0,sizeof(a)); fo原创 2013-08-13 21:04:10 · 710 阅读 · 0 评论 -
【HDOJ】1019 -> Least Common Multiple
心得: n个数的最小公倍数,两两求即可。代码:#include using namespace std;int gcd(int a,int b){ if(!b) return a; else return gcd(b,a%b);}int main(){ int N,n,x,y; cin>>N; while(N--){ ci原创 2013-08-13 10:50:05 · 476 阅读 · 0 评论 -
【HDOJ】1056 -> HangOver
心得: 二分查找代码:#include using namespace std;int bsearch(int l,int r,double k,double a[]){ //二分查找 int m; while(l<=r){ m=(l+r)/2; if(k>a[m-1] && k<=a[m]) break; else if(k>a[m])原创 2013-08-14 21:12:34 · 565 阅读 · 0 评论 -
【HDOJ】1028 -> Ignatius and the Princess III
心得: 利用母函数,求(1+x+x^2+...+x^n)*(1+x^2+x^4+...+x^2(n/2))*.......*(1+x^n)展开式x^n项的系数即可。代码:#include using namespace std; const int LEN=1000;int main(){ int n,i,j,k,temp; int c1[LEN],原创 2013-08-13 17:57:15 · 654 阅读 · 0 评论 -
【HDOJ】1005 -> Number Sequence
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1005心得: 在OJ平台、博客等很多地方看到有人称此题的循环节为48,并得到了AC,可能是测试数据覆盖范围过小的缘故,我只能说你们得逞了。下图是某网友的AC算法:#includeint main(){ long a,b,n,i,f[100]; whil原创 2013-08-15 07:49:50 · 655 阅读 · 0 评论 -
【HDOJ】1014 -> Uniform Generator
心得: 本题可转化为证明step与mod互质,因为若step与mod不互质,则seed[gcd(step,mod)]=0。代码:#include using namespace std;int gcd(int a,int b){ if(!b) return a; return gcd(b,a%b);}int main(){原创 2013-08-12 21:49:57 · 586 阅读 · 0 评论 -
【HDOJ】1070 -> Milk
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1070心得: 最大的体会就是这个叫做Ignatius的高帅富牛奶少于200ml就倒掉,5天喝不完的牛奶还要买。勤俭节约的孩纸不要学习他哦!代码:#include using namespace std;typedef struct{ char bra原创 2013-08-15 13:41:44 · 729 阅读 · 0 评论 -
【HDOJ】1097 -> A hard puzzle
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1097心得: 个位数相乘公共周期为4,。简单题就要一次AC!代码:#include using namespace std;int main(){ int t[10][5]= {{0,0,0,0},{1,1,1,1},{6,2,4,8},{1,3原创 2013-08-15 20:37:56 · 559 阅读 · 0 评论 -
【HDOJ】1163 -> Eddy's digital Roots
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1163心得: 九余数定理:一个数的九余数等于这个数各位数之和的九余数。换而言之,就是一个数每mod9一次,就相当于这个数的各位数相加再mod9一次。再换而言之,就是一个数的各位数之和mod9的值恒等于它本身mod9的值,并且与它本身mod9多少次没有关系!原创 2013-08-16 00:50:35 · 599 阅读 · 0 评论 -
【HDOJ】题目分类
基础题:1000、1001、1004、1005、1008、1012、1013、1014、1017、1019、1021、1028、1029、1032、1037、1040、1048、1056、1058、1061、1070、1076、1089、1090、1091、1092、1093、1094、1095、1096、1097、1098、1106、1108、1157、1163、1164、1170、1194、1原创 2013-08-12 18:25:57 · 886 阅读 · 0 评论