• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
 






goodniao_1

 
 

Powered by 博客园
博客园 | 首页 | 新随笔 | 联系 | 订阅 订阅 | 管理
上一页 1 2 3 4 5 6 7 8 9 10 ··· 15 下一页

2014年4月10日

hdu 1754 I Hate It 线段树 单点更新 求区间最值
摘要: 题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=1754接下来有M行。每一行有一个字符 C (只取'Q'或'U') ,和两个正整数A,B。当C为'Q'的时候,表示这是一条询问操作,它询问ID从A到B(包括A,B)的学生当中,成绩最高的是多少。当C为'U'的时候,表示这是一条更新操作,要求把ID为A的学生的成绩更改为B。代码如下:const int Max_N = 200005;int Max[Max_N>1; make_tree(L, mid , root>1; if(id 阅读全文
posted @ 2014-04-10 17:01 goodniao_1 阅读(142) 评论(0) 推荐(0)
 
zoj 3772 Calculate the Function 矩阵相乘+ 线段树查询
摘要: 题目来源:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3772分析:公式来源:http://blog.csdn.net/u013491262/article/details/23089957#comments代码如下:const int Mod=1000000007;struct Mat{ LL a[2][2]; Mat(){ memset(a,0,sizeof(a)); } Mat( LL a01) { a[0][0]=1; a[0][1]=a... 阅读全文
posted @ 2014-04-10 14:23 goodniao_1 阅读(224) 评论(0) 推荐(0)
 

2014年4月9日

Five Tiger 湘潭省赛 vector的应用
摘要: 题目来源:http://202.197.224.59/OnlineJudge2/index.php/Problem/read/id/1173代码如下:vector >Little5; // 每个单元是一个点的坐标vector > >AllLittle5; // 每个单元放的是5个点,即一个点数组void Init(){ //计算所有5虎的坐标 Little5.clear(); Little5.push_back(make_pair(0,0)); Little5.push_back(make_pair(0,2)); Little5.push_back(make_pair(... 阅读全文
posted @ 2014-04-09 22:58 goodniao_1 阅读(178) 评论(0) 推荐(0)
 
poj 1740 A New Stone Game 博弈
摘要: 题目来源:http://poj.org/problem?id=1740分析:均势为: 偶数堆,且 x,x, y,y,z,z... 即先人无论怎么取,后人跟先人一个走法,那么后人一定取最后一堆。为N势否则,就是必胜态P。代码如下:#include #include #include #include #include #include #include #include#include #include #include #include #include #include #include #include using namespace std ;typedef long long LL ; 阅读全文
posted @ 2014-04-09 17:47 goodniao_1 阅读(152) 评论(0) 推荐(0)
 
zoj 3203 Light Bulb 三分,求凸函数的最大值
摘要: 题目来源:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3366分析:求影子最长。当人从灯往墙走距离x,当 x0=D*(H-h)/H 时,x (0.x0)一直递增。当 D>x > x0 影子函数为f(x) = -x + (D*h -D*H) / x + D + H 为一个 凸函数。在此区间用三分,求最大值。代码如下:const double EPS=1e-9;double D,h,H;double f(double x){ return -x + (D*h - D*H) /x + D +H;}//三分 对凹(凸 阅读全文
posted @ 2014-04-09 17:06 goodniao_1 阅读(367) 评论(0) 推荐(0)
 
湘潭大学 Hurry Up 三分,求凹函数的最小值问题
摘要: 题目来源:http://202.197.224.59/OnlineJudge2/index.php/Problem/read/id/1175分析:起点和终点, 从起点跑到x轴,然后再从x轴某处到终点坐出租车,求最短时间,此函数为 f(x)。 然后再和直接从起点到终点的时间比较,求最小。由此,我们知道 f(x)是一个 凹函数,用三分的方法。代码如下:const double EPS=1e-9;double xs,ys,xe,ye,vr,vt;double f(double x){ return sqrt( (xs-x)*(xs-x) + ys*ys ) / vr + sqr... 阅读全文
posted @ 2014-04-09 15:23 goodniao_1 阅读(300) 评论(0) 推荐(1)
 
hdu 1166 线段树 单点修改 + 询问区间求和 (线段树模板)
摘要: 题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=1166借鉴大牛李的线段树模板const int Max_N=50100;int sum[Max_N>1; make_tree(L, mid, root>1; if(id>1; if(mid >= r) return query(l,r,L, mid, root>1; int ans=0; if(lmid) ans += query(l, r, mid+1, R, root#include #include #include #in... 阅读全文
posted @ 2014-04-09 10:23 goodniao_1 阅读(243) 评论(0) 推荐(0)
 

2014年4月8日

hdu 1166 树状数组(模板) 更改点值+求区间和
摘要: 题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=1166代码如下:using namespace std ;typedef long long LL;const int Max_N=50010;int cc[Max_N]; // 树状数组,有ci = A(i-lowbit(i)+1) + A(i-lowbit(i)+2)+ Aiint n;// 数组A的个数,下标从1开始int lowbit(int x){//lowbit 求的是 x的二进制表达式中最右边的1所对应的值 return x & -x;}void Add(int x, int 阅读全文
posted @ 2014-04-08 20:39 goodniao_1 阅读(203) 评论(0) 推荐(0)
 

2014年4月6日

getline
摘要: string s;getline(cin,s); 读一行字符串,读入时不会舍弃缓冲区的最后回车符,故有时 需要getchar().,读入后会舍弃掉最后回车符,并加入\0。scanf():读取字符串时,读入时会舍弃缓冲区的最后的回车符。对于字符:cin的输入忽略空格和回车。scanf("%c",&i)等价于i = getchar(),换行符和回车都会被读入。char str[100]; gets(str). 读入一行字符串后面的换行符和回车。第一:要注意不同的函数是否接受空格符、是否舍弃最后的回车符的问题。读取字符时:scanf()以Space、Enter、Tab结束 阅读全文
posted @ 2014-04-06 15:16 goodniao_1 阅读(219) 评论(0) 推荐(0)
 

2014年4月4日

poj 1873 The Fortified Forest 凸包+位运算枚举 world final 水题
摘要: 题目来源:http://poj.org/problem?id=1873题意:给出n棵树的坐标,树的高度和树的价值,从这些树中砍掉一些(整棵整棵的)做围栏把剩余的树围起来,使得消耗的树的价值最小。输出应砍掉哪里些树以及剩余的材料的长度。(如果砍掉的价值相同,则取砍掉数目少的)(2 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std ;type 阅读全文
posted @ 2014-04-04 20:21 goodniao_1 阅读(207) 评论(0) 推荐(0)
 
上一页 1 2 3 4 5 6 7 8 9 10 ··· 15 下一页