上一页 1 ··· 28 29 30 31 32 33 34 35 36 ··· 47 下一页

2012年5月25日

摘要: 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 阅读(203) 评论(0) 推荐(0) 编辑
 
摘要: 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 阅读(225) 评论(0) 推荐(0) 编辑
 
摘要: 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 阅读(209) 评论(0) 推荐(0) 编辑
 
摘要: 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 阅读(216) 评论(0) 推荐(0) 编辑
 
摘要: 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 阅读(166) 评论(0) 推荐(0) 编辑
 
摘要: 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 阅读(124) 评论(0) 推荐(0) 编辑
 
摘要: 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 阅读(164) 评论(0) 推荐(0) 编辑
 
摘要: 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 阅读(161) 评论(0) 推荐(0) 编辑
 
摘要: 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 阅读(288) 评论(0) 推荐(0) 编辑

2012年5月24日

摘要: 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 阅读(206) 评论(0) 推荐(0) 编辑
上一页 1 ··· 28 29 30 31 32 33 34 35 36 ··· 47 下一页