HDU 1257 最少拦截系统
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1257和POJ和2533一模一样。。。View Code #include <stdio.h>#include <string.h>#include <stdlib.h>int cmp(const void*a,const void*b){ return *(int*)b-*(int*)a;}int main(){ int n,i,j; int a[1100],dp[1100]; while(~scanf("%d",&n)) { for(i=0;
阅读全文
POJ 2533 Longest Ordered Subsequence
摘要:http://poj.org/problem?id=2533最长上升子序列,dpView Code #include <stdio.h>#include <string.h>#include <stdlib.h>int cmp(const void*a,const void*b){ return *(int*)b-*(int*)a;}int main(){ int n,i,j; int a[1100],dp[1100]; while(~scanf("%d",&n)) { for(i=0;i<n;i++) scanf(&quo
阅读全文
HDU 1163 Eddy's digital Roots
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1163脑袋疼的厉害,写完没调试直接交,居然把%d写成%c,导致wa一次。。。这题感觉前两天刚做过一道一样的。。。HDOJ的题目很多无脑重复啊。。View Code #include <stdio.h>int main(){ int n; int i,s; while(scanf("%d",&n),n) { s=1; for(i=0;i<n;i++) s=s*n%9; if(s==0) printf("...
阅读全文
HDU 1231 最大连续子序列
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1231最大连续子序列,水View Code #include <stdio.h>#include <stdlib.h>int cmp(const void*a,const void*b){ return *(int*)b-*(int*)a;}int a[110000];int main(){ int n,i; int max,now; int start,end; int temp; int p,q; while(scanf("%d",&n),n) { ..
阅读全文
HDU 2571 命运
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2571dp。wa两次,设边从1开始,所以和0有关的除了ans[1][0]和ans[0][1]外都要初始化为无穷(不让从外面进来)View Code #include <stdio.h>int map[30][1100];int ans[30][1100];#define INF -100000000int max(int a,int b){ return a>b?a:b;}int main(){ int n,m; int t; int i,j,k; scanf("%d",
阅读全文
HDU 4224 Enumeration?
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4224。。。对这题目无语了,本来是秒杀的题目就是让你读不懂。。。View Code #include <stdio.h>#include <string.h>#include <stdlib.h>int main(){ int x1,y1,x2,y2,x3,y3; int t,nCase=1; scanf("%d",&t); while(t--) { scanf("%d%d%d%d%d%d",&x1,&y1,&
阅读全文
HDU 4147 KFC -Z+W
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4147小学生英文阅读题View Code #include <stdio.h>#include <string.h>#include <stdlib.h>#define INF 100000000int main(){ int n,B,D,f,F; int sum,min,len; int i,j; char s[1100]; while(~scanf("%d%d%d%d%d%*c",&n,&B,&D,&f,&F)
阅读全文
HDU 4148 Length of S(n)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4148找规律,后一项描述前一项每一段有多少连续的相同数字。ps:算到30项,总共的长度也不小了,开始s数组开小了,一直运行出错,郁闷好一会View Code #include <stdio.h>#include <string.h>#include <stdlib.h>char s[40][11000];int main(){ int n,i,j; int cnt,f; s[1][0]='1'; s[1][1]='\0'; for(i=2;i
阅读全文
HDU 1326 Box of Bricks
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1326水,不过PE两次,囧View Code #include <stdio.h>#include <stdlib.h>int cmp(const void*a,const void*b){ return *(int*)b-*(int*)a;}int main(){ int n,i,s,av,bz; int h[60]; int nCase=1; while(scanf("%d",&n),n) { s=bz=0; for(i=0;i<n;i++)...
阅读全文
HDU 1298 Hat’s IEEE
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1289对二进制数进行位运算。首先可以百度一下IEEE 754的规则。以6560.91为例:6560.91的二进制表示为1100110100000.111010001111010111,写成科学计数法就是1.100110100000111010001111010111 * 2^12s有一位,是符号位,为正数,符号位是0。e有八位,代表二进制数的指数,这时e就是12(sample输出的第一个数)。f代表有效部分,有23位,为100110100000111010001111010111 。所以,符号位是0然后用它的
阅读全文
AHU 501 送钱活动
摘要:http://icpc.ahu.edu.cn/OJ/Problem.aspx?id=501和hdu1024一模一样,随便改改就过了。。。ps:安徽大学oj这个经验值系统真好玩、、View Code #include <stdio.h>#include <string.h>#include <stdlib.h>#define INF -100000000int max(int a,int b){ return a>b?a:b;}int a[1100000],p[1100000],q[1100000],now[1100000],pro[1100000];/
阅读全文
HDU 1024 Max Sum Plus Plus
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1024求m个子段的最大和。思路见代码注释。View Code #include <stdio.h>#include <string.h>#include <stdlib.h>#define INF -100000000int max(int a,int b){ return a>b?a:b;}int a[1100000],now[1100000],pro[1100000];//now记录当前最大值,pro记录前一个的最大值 int main(){ int n,m,i,
阅读全文
HDU 3752 Is the one been second-killed first?
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3752捅死一只萌萌~View Code #include <stdio.h>int main(){ int t,m,n,i; scanf("%d",&t); while(t--) { scanf("%d%d",&m,&n); for(i=0;i<n-1;i++) m-=2; puts(m%2?"NO":"YES"); } return 0;}
阅读全文
HDU 2537 8球胜负
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2537模拟View Code #include <stdio.h>char a[100];int n;int gao(){ int r,y,i; r=y=7; for(i=0;i<n;i++) { if(a[i]=='R')r--; if(a[i]=='Y')y--; if(a[i]=='B'&&r==0)return 1; if(a[i]=='B'&&r!=0)return 0; if(a[i]
阅读全文
HDU 1106 排序
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1106直接做不太方便,在网上新学一招。atoi这个函数原来做进制转换的时候就接触过。如果第一个非空格字符不存在或者不是数字也不是正负号则返回零,否则开始做类型转换,之后检测到非数字(包括结束符 \0) 字符时停止转换,返回整型数。(百度百科)简而言之是一个把字符型数字转化成整型的函数。strtok函数,感觉这个比较新鲜。下面从百度百科摘点介绍:原型 char *strtok(char *s, const char *delim);功能 分解字符串为一组字符串。s为要分解的字符串,delim为分隔符字符串。..
阅读全文
HDU 1013 Digital Roots
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1013按要求模拟View Code #include <stdio.h>#include <string.h>int main(){ int n; char a[1100]; while(gets(a)) { if(a[0]=='0')break; int len=strlen(a); n=0; for(int i=0;i<len;i++) { n+=a[i]-'0'; n...
阅读全文
HDU 1718 Rank
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1718求给定学号在所有人里面的排名View Code #include <stdio.h>int main(){ int gd; int a[1100],b[1100]; int i; while(~scanf("%d",&gd)) { int cnt=0; while(scanf("%d%d",a+cnt,b+cnt),(a[cnt]||b[cnt])) cnt++; for(i=0;i<cnt;i++) ...
阅读全文
HDU 2143 box
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2143除数为0re一次,用除法wa一次,加减互逆,乘除互逆,二者有一即可,这道题用除法会出问题。View Code #include <stdio.h>#include <string.h>#include <math.h>#include <stdlib.h>__int64 a,b,c;int gao(){ if(a*b==c||a*c==b||b*c==a||a+b==c||a+c==b||b+c==a)return 1; if(a!=0) if(b%a==
阅读全文
HDU 2148 Score
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2148View Code #include <stdio.h>#include <string.h>#include <math.h>#include <stdlib.h>int main(){ int t,n,l; int i; int s[1100]; scanf("%d",&t); while(t--) { scanf("%d%d",&n,&l); for(i=1;i<=n;i++) s
阅读全文
HDU 1847 Good Luck in CET-4 Everybody!
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1847如果j-A[i]是必败态,j就是必胜态,显然0必败,一个dp的过程#include #include #include using namespace std;int A[15], win[1005];int...
阅读全文
|
|