摘要: 擅长计算的小明对数字很感兴趣,关于计算方面的都很在行。不过现在他遇到了一个难题:他想区间[L,R]内所有数的各个位之和,我想这肯定难不倒你,那么如果让你求所有数在k进制表示下的各个位之和呢?你能帮他吗?输入多组测试数据(不超过10000组).每行有三个数字L,R,k(0<=L<=R<10^15,k<=20).这题思路不是问题,我调试了大半天才搞出来,一般的计数问题,要是比赛碰上了,肯定做不出代码:#include <iostream>#include <cstring>using namespace std;typedef long long L 阅读全文
posted @ 2013-04-07 20:27 fly_lovelove 阅读(269) 评论(0) 推荐(0) 编辑
摘要: 简单的贪心:代码:View Code #include <cstdio>#include <set>#include <algorithm>#include <cstring>using namespace std;#define N 100005struct st{ int d,p;}num[N];multiset<int> v;int fan(struct st A,struct st B){ if(A.p < B.p ||(A.p == B.p && A.d < B.d)) return 1; ret 阅读全文
posted @ 2013-04-02 20:20 fly_lovelove 阅读(198) 评论(0) 推荐(0) 编辑
摘要: 问题描述Death-Moon loves telling stories. Some days ago, he told us a funny story. Long long ago, there is a hamster who is so naughty. Now, he comes to a place likes a N * N square. so, he is so excited to drill holes underground. 输入Input until EOF. Fisrt input two integers N (3 <= N < 100) and M 阅读全文
posted @ 2013-04-02 11:42 fly_lovelove 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 题目意思:求递增的最短路思路,先对所有边进行排序,逐层进行算最短路代码:View Code 1 #include <cstdio> 2 #include <iostream> 3 #include <algorithm> 4 #include <cstring> 5 using namespace std; 6 #define M 50001 7 #define N 10001 8 __int64 inf = 10000000000000000LL; 9 struct st10 {11 int u,v,w;12 }p[M];13 __int64 阅读全文
posted @ 2013-04-01 11:50 fly_lovelove 阅读(178) 评论(1) 推荐(0) 编辑
摘要: 题目意思:求最长路径,先了解树的直经随着杭州西湖的知名度的进一步提升,园林规划专家湫湫希望设计出一条新的经典观光线路,根据老板马小腾的指示,新的风景线最好能建成环形,如果没有条件建成环形,那就建的越长越好。 现在已经勘探确定了n个位置可以用来建设,在它们之间也勘探确定了m条可以设计的路线以及他们的长度。请问是否能够建成环形的风景线?如果不能,风景线最长能够达到多少? 其中,可以兴建的路线均是双向的,他们之间的长度均大于0。代码如下:View Code 1 #include <cstdio> 2 #include <queue> 3 #include <cstrin 阅读全文
posted @ 2013-03-29 13:43 fly_lovelove 阅读(188) 评论(0) 推荐(0) 编辑
摘要: 题目:腾讯第二届第二场的比赛,我这种若菜比赛时,就没做出来,也是赛后听人指导才做出的哦!!!吉哥这几天对队形比较感兴趣。 有一天,有n个人按顺序站在他的面前,他们的身高分别是h[1], h[2] ... h[n],吉哥希望从中挑出一些人,让这些人形成一个新的队形,新的队形若满足以下三点要求,则称之为完美队形: 1、挑出的人保持他们在原队形的相对顺序不变; 2、左右对称,假设有m个人形成新的队形,则第1个人和第m个人身高相同,第2个人和第m-1个人身高相同,依此类推,当然,如果m是奇数,中间那个人可以任意; 3、从左到中间那个人,身高需保证递增,如果用H表示新队形的高度,则H[1] ... 阅读全文
posted @ 2013-03-23 14:58 fly_lovelove 阅读(239) 评论(0) 推荐(0) 编辑
摘要: 题意:给出一个圆和一个矩形,判断2图形是否相交,(相切也算)。注意思考的要全面代码:View Code 1 #include <cstdio> 2 #include <cmath> 3 #include <iostream> 4 using namespace std; 5 struct st 6 { 7 double x,y; 8 }; 9 double r;10 double dis(st A,st B)11 {12 return sqrt((A.x - B.x) * (A.x - B.x) + (A.y - B.y) * ( A.y - B.y));1 阅读全文
posted @ 2013-03-20 09:28 fly_lovelove 阅读(293) 评论(0) 推荐(0) 编辑
摘要: 题意:给出n个数,定义num为任意区间的最大值和次大值得异或,求num的最大值思路:枚举每一个数作为次大值,那么最大值可以用线段树找次大数右边或左边的第一个比他大的数,这样就找到最大值了样例:55 2 1 4 3答案为:7代码:#include <cstdio>#include <iostream>using namespace std;#define N 100001int a[N];struct st{ int x,y,m;}p[N * 4];void build(int r,int x,int y){ p[r].x = x;p[r].y = y; if(x == 阅读全文
posted @ 2013-03-19 12:17 fly_lovelove 阅读(904) 评论(0) 推荐(0) 编辑
摘要: 今天的c++,正朝着精英化方向发展,想搞好c++太难了,要学的东西太多了,没若干年你别想有所成就目前在学生时代关于我个人要学的东西主要:c++基础,c++ stl,算法与数据结构,c++网络编程,c++多线程编程,了解网络原理和操作系统,个人就业方面还是向往游戏这个方向发展,大学最开心最激动的做的一件事还是我的ACM,居然跟它打交道花了我几乎整个大学的时光,虽然自己智商不算太高,搞的不怎么样,可自己感觉也够满足了,呵呵,以后出去,有空再偶尔做做acm吧,因为搞acm太爽了,呵呵! 阅读全文
posted @ 2013-03-10 21:38 fly_lovelove 阅读(235) 评论(1) 推荐(0) 编辑
摘要: 题目:We have a rope whose length is L. We will cut the rope into two or more parts, the length of each part must be an integer, and no two parts have the same length. Your task is to calculate there exists how many results after the cutting. We say two results are different if and only if there is at. 阅读全文
posted @ 2013-03-10 21:22 fly_lovelove 阅读(191) 评论(0) 推荐(0) 编辑