自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

  • 博客(43)
  • 资源 (1)
  • 收藏
  • 关注

转载 a^b%m 快速幂

b为偶数时 a^b%c = (a*a)^(b/2) b为奇数时 a^b%c = a*(a*a)^(b/2) m^n % k 的快速幂: // m^n % k int quickpow(int m,int n,int k) { int b =1; while (n >0) { if (n &1) b = (b*m)%k; n = n >>1 ; m = (

2013-03-06 16:02:14 308

原创 hdu 4251

直接模版 求中位数 #include #include #include using namespace std; int const NCNT = 100010; struct node { int l,r; }tree[NCNT*4]; int deep[20][NCNT],num_left[20][NCNT]; int a[NCNT]; void build(int id,int

2012-11-30 16:45:41 212

原创 划分树 hdu 2665

大概已经学会如何使用划分树···但还不够熟练···争取以后能灵活使用划分树··· #include #include #include using namespace std; int const NCNT = 100010; struct node { int l,r; }tree[NCNT*4]; int deep[20][NCNT],num_left[20][NCNT];

2012-11-30 16:11:17 235

原创 codeforces 250E Mad Joe

纯模拟 用 l, r 来记录在当层走过的最左边,和最右边; #include #include #include #include using namespace std; char map[110][10100]; int main() { int n,m; while(~scanf("%d%d",&n,&m)) { for(int i=0;i<n;i

2012-11-27 20:47:47 402

原创 划分树学习 poj 2104

开始学习划分树······ 虽然还不是很懂····大概的思路还是看懂了···先排序,然后对没排序的数按大小分开到两边····num_left记录自己左边有多少分到左边用于查询···· 按照网上的题目大概敲了下···还有些不懂的地方···尤其是查询···还不是很懂···下次在看懂  下面是这题的代码·· #include #include #include using namespac

2012-11-22 22:08:03 211

原创 hdu 1733

第一次这样建图   每秒一层···每层的点拆成2个 一个出 一个入  容量为1,建图很麻烦 ··· #include #include #include using namespace std; int const ncnt = 200000; struct edge { int u,v,flow,next; }e[1000000];int ecnt; int n,m; char

2012-11-16 14:07:21 310

原创 hdu 2732

无语wa了很多次  后来复制了别个的输出  就ac了     文本对比了一下  坑死   was 打的 were 下次要注意··· #include #include #include using namespace std; struct edge { int u,v,flow,next; }e[200000];int ecnt; int head[1000]; char ma

2012-11-14 22:06:48 342

原创 poj 3469

#include #include #include using namespace std; struct edge { int u,v,flow,next; }e[1000000];int ecnt; int head[30000]; int const inf = 1<<30; void addedge(int u,int v,int flow) { e[ecnt].u =

2012-11-13 16:35:36 174

原创 hdu 3046

最小割,每个格子边容量为1,所以最大流=最小割 #include #include #include using namespace std; int map[210][210]; int const inf = 1<<30; struct edge { int u,v,flow,next; } e[444444]; int ecnt; int head[100000]; void ad

2012-11-13 15:09:45 258

原创 hdu 1018

求n!的位数 log10(n!)得到的数向上去整就是位数  log10(n!) 算的是n!的位数-1,因为是10^x ,10^2 = 100 3位数, #include #include #include using namespace std; int main() { int t,n; double ans; scanf("%d",&t); whil

2012-11-10 21:03:43 340

原创 hdu 4268

iterator lower_bound( const key_type &key ): 返回一个迭代器,指向键值>= key的第一个元素。   iterator upper_bound( const key_type &key ):返回一个迭代器,指向键值> key的第一个元素。对Alice和Bob的数据一起排序,再贪Alice离Bob最进的矩形对 #include #include #inc

2012-11-10 13:58:10 681 2

转载 输入外挂

int Scan() { int res = 0, ch, flag = 0; if((ch = getchar()) == '-') //判断正负 flag = 1; else if(ch >= '0' && ch <= '9') //得到完整的数 res = ch - '0'; while((ch = getchar()) >= '0' && ch <= '9'

2012-11-10 13:51:52 207

原创 poj 3678 2-sat

#include #include #include using namespace std; struct edge { int from,to,next; }e[10000000]; int head[2000],ecnt; void addedge(int from,int to) { e[ecnt].from = from; e[ecnt].to = to;

2012-11-01 21:51:03 210

原创 hdu 2296 2-sat

#include #include #include #include using namespace std; struct node { int x,y; }no[110]; int n; struct edge { int from,to,next; }e[40010]; int ecnt; int head[220]; void addedge(int from,int

2012-10-31 22:10:26 325

原创 2-sat poj 3207 Ikki's Story IV - Panda's Trick

#include #include #include using namespace std; struct node { int u,v; }no[1100]; struct edge { int from,to,next; }e[1000100]; int head[1100]; int ecnt; int n,m; void addedge(int from,int t

2012-10-31 14:19:39 544

原创 2-sat hdu 3062

一、关于模型: 一个2-SAT模型应该是一个满足以下的条件的满足性问题:  1、该模型中存在2n个可以分成n组的元素,每组两个元素。  2、每组元素中,选择了其中一个元素,另外一个元素就不能被选择。这两个元素记为a和!a。  3、该模型中的元素之间存在一些关系,且这些关系是对称的。(除非是同一组元素中的关系,这些关系限定了“必须选择”该组中的某一个元素,可能单独出现)比如NOT(A[x] A

2012-10-29 21:34:29 369

原创 zoj 1094 Matrix Chain Multiplication

#include #include #include using namespace std; struct Mat { int x,y; }mat[26]; char str[100]; bool flag; int t; stack ma; int MatRide (Mat &a,Mat b) { if ( a.y == b.x

2012-10-25 22:01:10 210

原创 %*c 吸收字符 n-1位数

#include #include using namespace std; int main() { int t,m; scanf("%d",&t); while (t--) { scanf("%*c%*c%d",&m); printf("%d\n",m); } }

2012-10-23 20:26:28 751

原创 stl map 众数问题

#include #include #include #include using namespace std; int main() { int t,n,a; scanf("%d",&t); while (t--) { map ma; map ::iterator it;

2012-10-23 13:48:39 292

原创 stack练习 汉诺塔(三)

#include #include #include using namespace std; int main() { int t,p,q,a,b; bool flag; scanf("%d",&t); while (t--) { stack han[3]; flag = true;

2012-10-22 20:29:42 455

原创 vector + 区间最大(min_element) + 区间最小(min_element)

#include #include #include using namespace std; int main() { vector v; int a; for (int i = 0; i < 5; i++) { scanf("%d", &a); v.push_back(a); }

2012-10-17 14:18:06 636

原创 一种排序 set 对结构体的排序 重载 <

#include #include #include #include using namespace std; struct Node { int key,len,wei; }q; bool operator < (const Node& r1,const Node& r2) { return r1.key<r2.key || r1.key=

2012-10-17 11:22:50 450

原创 擅长排列的小明 string + next_permutation 全排列

#include  #include  #include  using namespace std;    int main()  {       int i,j,k,T;       cin>>T;       while(T--)       {            int x,y;            string s1,s2;            ci

2012-10-17 11:20:54 312

原创 Binary String Matching -- stl string 常用函数

#include #include #include using namespace std; int main() { string s,a; int t; scanf("%d",&t); while (t--) { cin >> a >> s; int al = a.length();

2012-10-15 17:25:20 292

原创 ASCII码排序 c++ list 练习

begin() //返回第一个元素的指针(iterator) clear() //删除所有元素 empty() //判断是否链表为空 end() //返回最后一个元素的下一位置的指针(list为空时end()=begin()) erase() //删除一个元素或一个区域的元素(两个重载) front() //返回第一个元素的引用 sort() //对链表排序,默认升序(可自定义)

2012-10-15 16:04:02 538

原创 括号配对问题 stack 练习

push(x) 入栈 pop()出栈 top() 访问栈顶 empty()判断栈空 为空返回true size() 栈中的元素个数 #include #include #include using namespace std; char change( char c ) { return c == ']' ? '[' : '('; } bool match( cha

2012-10-15 15:23:46 283

原创 纪念第一次省赛---Shortest Names

第一次省赛草草结束····留下了无数的遗憾···这在省赛卡到的题目···因为自己比较紧张 把 ‘a’  打成了 ‘A’   导致 第一个输入的总是对的  第二次 一样的数据也会错····一直以为是初始化问题···认为指针混乱···总之留下了无数的遗憾···真心对不起自己的队友···下面贴代码···· #include #include using namespace std; struct N

2012-10-14 20:09:38 653

原创 三角型角平分线与对边的交点

ab/ac = bd/dc 角平分线定理 #include #include #include using namespace std; struct Point { double x,y; }a,b,c,d; double dis(Point a,Point b) { return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-

2012-10-08 21:32:11 502

原创 凸包+卡壳 最远点对

#include #include #include using namespace std; struct Point { long long x,y; }point[100000],res[100000]; bool cmp(Point a,Point b) { return a.y<b.y||(a.y==b.y&&a.x<b.x); }

2012-10-07 16:52:28 235

原创 tyvj 多边形统计

#include #include #include #include using namespace std; struct node { double x,y; }point[20],res[20]; bool cmp (node a,node b) { return a.y<b.y||(a.y==b.y&&a.x<b.x); }

2012-10-04 15:52:26 212

原创 tyvj 放置国王

找对称中心所以x轴对称,y轴对称,分别讨论就可以了··· #include #include #include using namespace std; int main() { int n; double x[20000],y[20000]; scanf("%d",&n); for(int i = 0;i<n;i++) scanf

2012-10-04 15:50:05 354

原创 hdu 4403 A very hard Aoshu problem

#include #include using namespace std; char str[20]; int l,ans; void dfs2(int j,__int64 sum,__int64 sum2,__int64 p) {      if (j==l)      {         if(sum==sum2)ans++;//printf("%I64d-

2012-09-25 11:58:33 240

原创 hdu 2200 C(n,m)

#include #include using namespace std; __int64 cal(__int64 m,__int64 n) { __int64 s=1,i; for(i=1;i<=m;i++) s=s*(n-i+1)/i; return s; } int main() { __int64 sum,i,n; while

2012-09-21 16:02:33 1564

原创 hdu 2108 Shape of HDU 凸包

#include #include using namespace std; int pk(int p1,int q1,int p2,int q2,int p3,int q3) { return ( p3 - p1 )*( q2 - q1 ) - ( q3 - q1 )*( p2 - p1 ); } int main() { int n,a,b,c,d,e,f,g,h

2012-09-20 13:19:21 469

原创 hdu 2106 decimal system

#include #include #include #include using namespace std; int getjz(char a[]) { int i = strlen(a) - 2; return a[i] == '0' ? 10 : a[i] - '0'; } int getsum(char a[],int jz) {

2012-09-19 21:18:35 264

原创 hdu 2104 hide handkerchief

/*出现第一个重复点一定会是你自己的位置,因为想到任何一个走过的点就必须先到你走过的点的前一个点,所以第一个出现重复的一定是起点,因为每个点都要走一次,所以总共要走n次m,并且在第n次走到第一个点,那么在第n次之前不存在一个i使得(m*i)% n = 0 也就是n和m的最大公倍数为n*m,也就是n,m互质,所有用辗转相除去解*/ #include #include using namespa

2012-09-19 19:15:58 291

原创 hdu 2100 Lovekey

#include #include #include using namespace std; int main() { char a[300],b[300]; while(~scanf("%s%s",a,b)) { strrev(a);strrev(b); int la = strlen(a);

2012-09-19 16:20:17 207

原创 SBT 营业额统计

size用于维护树的深度,值为自己和孩子的总数; #include #include using namespace std; int abs(int a) { return a > 0 ? a : -a; } struct Tree_node { int key,size,left,right; }SBT_Tree[40000]; int

2012-09-15 13:51:42 262

原创 hdu 3987 Harry Potter and the Forbidden Forest

第2道 sap算法练习   #include #include using namespace std; int const inf = 1<<30; struct Edge { int v,c,next; }edge[600000]; int e; int pre[1010],cur[1010],gap[1010],dis[1010],head[1010]

2012-09-05 21:40:22 228

原创 hdu 1532 Drainage Ditches

#include #include using namespace std; int const inf = 1<<30; struct Edge { int u,v,c,next; }edge[500]; int e; int n,m; int pre[210],cur[210],dis[210],gap[210],head[210]; void add_ed

2012-09-05 20:42:45 239

cocos2dx msvc

install-templates-msvc.bat

2014-04-09

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除