随笔分类 -  2012-1000系列

上一页 1 2 3 4 5 6 7 8 9 ··· 13 下一页

 
HDU 1203 I NEED A OFFER!
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=120301背包ps:做01背包经常不注意数组的大小,这题数组开小了又是各种waView Code #include <iostream>using namespace std ;double f[10001],w[1001];int c[1001];int main(){ int n,m; while(scanf("%d%d",&n,&m)) { if(n==0&&m==0)break; for(int i=1;i<=m;i++) scan 阅读全文
posted @ 2012-05-27 23:16 LegendaryAC 阅读(149) 评论(0) 推荐(0)
HDU 2546 饭卡
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=254601背包,开始内层循环写成v>=0无限wa。。。一定要注意数组越界的问题、、、View Code #include <iostream>using namespace std ;int main(){ int n; while(scanf("%d",&n),n) { int w[1010]; int maxx=0; int flag; for(int i=1;i<=n;i++) { scanf(... 阅读全文
posted @ 2012-05-27 22:38 LegendaryAC 阅读(196) 评论(0) 推荐(0)
HDU 1009 FatMouse' Trade
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1009无聊的贪心View Code #include <stdio.h>#include <stdlib.h>typedef struct L{ int j,k; double w;}L;L kk[1001];int cmp(const void*a,const void*b){ L*c=(L*)a; L*d=(L*)b; return d->w > c->w ? 1 : -1 ;}int main(){ int m,n; while(scanf("%d%d 阅读全文
posted @ 2012-05-27 16:45 LegendaryAC 阅读(128) 评论(0) 推荐(0)
HDU 2539 点球大战
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2539无聊题,可能会有人名开头小写的数据,所以一定要倒着找no,我这种写法是中间出了点故障,导致写的很麻烦,不足取View Code #include <iostream>#include <string>using namespace std ;int main(){ int n; while(scanf("%d%*c",&n),n) { int flag1[10],flag2[10]; char str[101]; int ans1=0,ans2... 阅读全文
posted @ 2012-05-27 16:17 LegendaryAC 阅读(290) 评论(0) 推荐(0)
HDU 1982 Kaitou Kid - The Phantom Thief (1)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1982字符串处理View Code #include <iostream>#include <string>using namespace std ;char str[27]={"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};int main(){ int t; scanf("%d%*c",&t); while(t--) { string s; cin >> s ; for(int i=0;i<s.lengt 阅读全文
posted @ 2012-05-27 10:04 LegendaryAC 阅读(194) 评论(0) 推荐(0)
HDU 1976 Software Version
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1976水题View Code #include <stdio.h>#include <string.h>int main(){ int t; int a1,a2,a3; int b1,b2,b3; scanf("%d",&t); while(t--) { scanf("%d%d%d",&a1,&a2,&a3); scanf("%d%d%d",&b1,&b2,&b3); i 阅读全文
posted @ 2012-05-26 22:49 LegendaryAC 阅读(175) 评论(0) 推荐(0)
HDU 1977 Consecutive sum II
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1977很容易看出规律View Code #include <stdio.h>#include <string.h>int main(){ int t; __int64 n; scanf("%d",&t); while(t--) { scanf("%I64d",&n); printf("%I64d %I64d\n",n*n*n,(n+1)*(n+1)*(n+1)); } return 0;} 阅读全文
posted @ 2012-05-26 21:00 LegendaryAC 阅读(127) 评论(0) 推荐(0)
HDU 3792 Twin Prime Conjecture
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3792n为负数,静态查询,用树状数组写,蛋疼可见一斑。打素数表的时候内层循环对i再加一个判断,是为了防止i*j因为溢出而恒真(引用自sx老祖)View Code #include <iostream>using namespace std ;const int MAX=100001;int prime[MAX],tree[MAX],num[MAX];int lowbit(int i){ return i&(-i);} void update(int x,int val){ for(int 阅读全文
posted @ 2012-05-25 14:37 LegendaryAC 阅读(321) 评论(0) 推荐(0)
HDU 2368 Alfredo's Pizza Restaurant
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2368初中数学题,圆幂定理View Code #include <iostream>using namespace std ;int main(){ double r,w,l; int nCase=1; while(scanf("%lf",&r),r) { scanf("%lf%lf",&w,&l); if(r*r-(w/2)*(w/2)<(l/2)*(l/2)) printf("Pizza %d does not f 阅读全文
posted @ 2012-05-25 12:55 LegendaryAC 阅读(177) 评论(0) 推荐(0)
HDU 1984 Mispelling4
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1984字符串处理View Code #include <iostream>#include <string>using namespace std;int main(){ int t,n; char str[110]; scanf("%d",&t); for(int cas=1;cas<=t;cas++) { scanf("%d %s",&n,str); str[n-1]='\0'; printf(" 阅读全文
posted @ 2012-05-25 06:22 LegendaryAC 阅读(172) 评论(0) 推荐(0)
HDU 1996 汉诺塔VI
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1996递推View Code #include <iostream>#include <string>using namespace std;int main(){ int t; __int64 dp[30]={0,3}; for(int i=2;i<30;i++) dp[i]=dp[i-1]*3; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); printf(&quo 阅读全文
posted @ 2012-05-25 05:26 LegendaryAC 阅读(210) 评论(0) 推荐(0)
HDU 1985 Conversions
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1985小学计算题View Code #include <iostream>#include <string>using namespace std;int main(){ int t; scanf("%d",&t); for(int cas=1;cas<=t;cas++) { double n; string d; cin >> n >> d; if(d=="kg") printf("%d %.4l 阅读全文
posted @ 2012-05-25 05:08 LegendaryAC 阅读(235) 评论(0) 推荐(0)
HDU 2393 Higher Math
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2393判断直角三角形View Code #include <stdio.h>#include <string.h>int main(){ int t; scanf("%d",&t); for(int cas=1;cas<=t;cas++) { int a,b,c; scanf("%d%d%d",&a,&b,&c); printf("Scenario #%d:\n",cas); if(a*a 阅读全文
posted @ 2012-05-25 04:31 LegendaryAC 阅读(220) 评论(0) 推荐(0)
HDU 2391 Filthy Rich
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2391一路逆着推过去View Code #include <stdio.h>#include <string.h>const int INF=100000000;int map[1001][1001],dp[1001][1001];int Max(int a,int b,int c){ int max=-INF; if(a>max)max=a; if(b>max)max=b; if(c>max)max=c; return max;}int main(){ int t. 阅读全文
posted @ 2012-05-25 04:04 LegendaryAC 阅读(224) 评论(0) 推荐(0)
HDU 1708 Fibonacci String
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1708不能直接用string加,最后的位数很多,会超内存。一定注意特殊处理k=0和k=1的情况。最后有空行View Code #include <iostream>#include <cstdlib>#include <cstring>#include <string>#include <stack>#include <queue>#include <map>#include <algorithm>using na 阅读全文
posted @ 2012-05-25 03:52 LegendaryAC 阅读(179) 评论(0) 推荐(0)
HDU 3501 Calculation 2
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3501继续欧拉函数,关键点是求小于n且与n互质的数的和。公式是Eular(n)*n/2,简略证明如下:原问题等价于一个数n,如果a与它互质,那么n-a也与它互质;反证法,假设n与a互质,n与n-a不互质设n和n-a的最大公约数为m,则n=p*m,n-a=q*m所以a=(p-q)*m,推导出a和n有公约数m,与假设矛盾View Code #include <iostream>#include <cstdlib>#include <cstring>#include <st 阅读全文
posted @ 2012-05-25 02:00 LegendaryAC 阅读(137) 评论(0) 推荐(0)
HDU 1787 GCD Again
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1787依然是欧拉函数的模板题,求有多少个小于等于N且不与N互质的数,减去N本身再减去和N互质的就好了,小于N且和N互质的数的个数就用欧拉函数算了View Code #include <iostream>#include <cstdlib>#include <cstring>#include <string>#include <stack>#include <queue>#include <map>#include <al 阅读全文
posted @ 2012-05-25 00:48 LegendaryAC 阅读(171) 评论(0) 推荐(0)
HDU 2824 The Euler function
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2824同上一题,裸欧拉函数View Code #include <iostream>#include <cstdlib>#include <cstring>#include <string>#include <stack>#include <queue>#include <map>#include <algorithm>using namespace std;const int MAX=3000001;int ph 阅读全文
posted @ 2012-05-25 00:09 LegendaryAC 阅读(168) 评论(0) 推荐(0)
HDU 1286 找新朋友
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1286裸欧拉函数,欧拉函数是求比n小的数中有多少个与n互质View Code #include <iostream>#include <cstdlib>#include <cstring>#include <string>#include <stack>#include <queue>#include <map>#include <algorithm>using namespace std;const int MA 阅读全文
posted @ 2012-05-25 00:04 LegendaryAC 阅读(298) 评论(0) 推荐(0)
HDU 4163 Stock Prices
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4163稳定排序View Code #include <iostream>#include <cstdlib>#include <cstring>#include <string>#include <stack>#include <queue>#include <map>using namespace std;typedef struct L{ int price; int idx;}L;L kk[1000001];int cm 阅读全文
posted @ 2012-05-24 23:19 LegendaryAC 阅读(212) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 7 8 9 ··· 13 下一页