桑海

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2013年2月23日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1003Max SumTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 49213Accepted Submission(s): 10950Problem DescriptionGiven a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-seque 阅读全文
posted @ 2013-02-23 00:19 桑海 阅读(323) 评论(0) 推荐(0) 编辑

2013年2月22日

摘要: Problem DescriptionI have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.InputThe first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line consists of two positive integers 阅读全文
posted @ 2013-02-22 10:10 桑海 阅读(550) 评论(0) 推荐(0) 编辑

2013年1月30日

摘要: 样例输入:4 23 410 12 28 12816 12345样例输出:127512325536358My Code 1 #include<iostream> 2 using namespace std; 3 const int maxn = 20; 4 5 int node[1<<maxn]; 6 int main() 7 { 8 int d, n; 9 while(cin >> d >> n)10 {11 int s = 1<<d;12 memset(node, 0, s);//初始化结点全部关闭13 int i;... 阅读全文
posted @ 2013-01-30 23:00 桑海 阅读(921) 评论(0) 推荐(2) 编辑

2013年1月27日

摘要: 编写一个 函数solve,给定浮点数a, b, c, d, e, f,求解方程组af + by = c, dx + ey = f;任务1:使用assert宏,让解不唯一时异常退出。任务1 1 #include<iostream> 2 #include<cassert> 3 using namespace std; 4 5 double x, y; 6 7 void solve(double a, double b, double c, double d, double e, double f) 8 { 9 assert(b*d!=a*e);10 y = (c*d-a*f 阅读全文
posted @ 2013-01-27 22:48 桑海 阅读(468) 评论(0) 推荐(1) 编辑

2013年1月21日

摘要: 以下来自百度文库,感觉很受用,转载如下: 原来可以将好东西放到博客上大家共享呀,刚刚知道。近些日子老在写程序,有VC,有Java的,都是最基础的东西,挑出一些我觉得挺好的,也拿来和大家分享吧: 侯捷先生这样说: 我总是鼓励 C/C++ 的学习者,在刚接触这个程式语言的时候,先以 console mode(DOS-like)程式为目标。换言之,不要一开始就想写 GUI 程式、想开视窗、想有眩目亮丽的... 阅读全文
posted @ 2013-01-21 16:45 桑海 阅读(2052) 评论(0) 推荐(0) 编辑

2012年12月29日

摘要: #include<iostream>#include<cstring>using namespace std;void out(char str[]){ for(int i = 0; str[i] != '\0'; ++i) cout << str[i]; cout << endl;}void f(char str[]){ out(str); memset(str, '0', sizeof(str)); out(str);}int main(){ char str[10] = "123456"; 阅读全文
posted @ 2012-12-29 23:12 桑海 阅读(798) 评论(0) 推荐(0) 编辑

2012年12月27日

摘要: 输入不超过1000的正整数n,输出n!的精度结果。样例输入:30样例输出:265252859812191058636308480000000#include<iostream>#include<string.h>using namespace std;const int maxn = 3000;int f[maxn];void out(int f[]){ int i, j; for(j = maxn - 1; j >= 0; --j) if(f[j]) break; for(i = j; i >= 0; --i) cout << f[i]; co 阅读全文
posted @ 2012-12-27 20:08 桑海 阅读(366) 评论(0) 推荐(0) 编辑

2012年12月25日

摘要: 如果n和n+2都是素数,则称他们是孪生素数。输入m,输出连个数均不超过m的最大孪生素数。5<=m<=10000.例如m=20时的答案是17、19,m=1000时的答案是881、883.Code 1 #include<iostream> 2 #include<cmath> 3 #include<assert.h> 4 using namespace std; 5 /* 6 bool is_primer(int x) 7 { 8 for(int i = 2; i*i <= x; ++i) //中间值可能会溢出 9 if(x%i == 0) re 阅读全文
posted @ 2012-12-25 14:01 桑海 阅读(800) 评论(0) 推荐(0) 编辑

2012年12月22日

该文被密码保护。 阅读全文
posted @ 2012-12-22 16:27 桑海 阅读(1) 评论(0) 推荐(0) 编辑

摘要: 期待给予指正与建议,愿共勉 习题3-1: 分数统计(stat) 输入一些学生的分数,那个分数出现的次数最多?如果有多个并列,从大到小输出。 任务一:分数均为不超过100的非负整数。 Code#include<iostream>#include<cstring>using namespace std;int main(){ int a[101], n; memset(a, 0, si... 阅读全文
posted @ 2012-12-22 11:47 桑海 阅读(1084) 评论(2) 推荐(0) 编辑