- 博客(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 % kint 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
245
原创 hdu 4251
直接模版 求中位数#include#include#includeusing 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
157
原创 划分树 hdu 2665
大概已经学会如何使用划分树···但还不够熟练···争取以后能灵活使用划分树···#include#include#includeusing 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
180
原创 codeforces 250E Mad Joe
纯模拟用 l, r 来记录在当层走过的最左边,和最右边;#include#include#include#includeusing 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
339
原创 划分树学习 poj 2104
开始学习划分树······虽然还不是很懂····大概的思路还是看懂了···先排序,然后对没排序的数按大小分开到两边····num_left记录自己左边有多少分到左边用于查询····按照网上的题目大概敲了下···还有些不懂的地方···尤其是查询···还不是很懂···下次在看懂 下面是这题的代码··#include#include#includeusing namespac
2012-11-22 22:08:03
161
原创 hdu 1733
第一次这样建图 每秒一层···每层的点拆成2个 一个出 一个入 容量为1,建图很麻烦 ···#include#include#includeusing 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
267
原创 hdu 2732
无语wa了很多次 后来复制了别个的输出 就ac了 文本对比了一下 坑死 was 打的 were 下次要注意···#include#include#includeusing namespace std;struct edge{ int u,v,flow,next;}e[200000];int ecnt;int head[1000];char ma
2012-11-14 22:06:48
309
原创 poj 3469
#include#include#includeusing 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
127
原创 hdu 3046
最小割,每个格子边容量为1,所以最大流=最小割#include#include#includeusing 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
224
原创 hdu 1018
求n!的位数 log10(n!)得到的数向上去整就是位数 log10(n!) 算的是n!的位数-1,因为是10^x ,10^2 = 100 3位数,#include#include#includeusing namespace std;int main(){ int t,n; double ans; scanf("%d",&t); whil
2012-11-10 21:03:43
309
原创 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
617
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
177
原创 poj 3678 2-sat
#include#include#includeusing 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
173
原创 hdu 2296 2-sat
#include#include#include#includeusing 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
291
原创 2-sat poj 3207 Ikki's Story IV - Panda's Trick
#include#include#includeusing 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
499
原创 2-sat hdu 3062
一、关于模型: 一个2-SAT模型应该是一个满足以下的条件的满足性问题: 1、该模型中存在2n个可以分成n组的元素,每组两个元素。 2、每组元素中,选择了其中一个元素,另外一个元素就不能被选择。这两个元素记为a和!a。 3、该模型中的元素之间存在一些关系,且这些关系是对称的。(除非是同一组元素中的关系,这些关系限定了“必须选择”该组中的某一个元素,可能单独出现)比如NOT(A[x] A
2012-10-29 21:34:29
320
原创 zoj 1094 Matrix Chain Multiplication
#include#include#includeusing 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
175
原创 %*c 吸收字符 n-1位数
#include#includeusing 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
711
原创 stl map 众数问题
#include#include#include#includeusing namespace std;int main(){ int t,n,a; scanf("%d",&t); while (t--) { map ma; map ::iterator it;
2012-10-23 13:48:39
245
原创 stack练习 汉诺塔(三)
#include#include#includeusing 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
410
原创 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
589
原创 一种排序 set 对结构体的排序 重载 <
#include#include#include#includeusing 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
408
原创 擅长排列的小明 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
261
原创 Binary String Matching -- stl string 常用函数
#include#include#includeusing 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
247
原创 ASCII码排序 c++ list 练习
begin() //返回第一个元素的指针(iterator)clear() //删除所有元素empty() //判断是否链表为空end() //返回最后一个元素的下一位置的指针(list为空时end()=begin())erase() //删除一个元素或一个区域的元素(两个重载)front() //返回第一个元素的引用sort() //对链表排序,默认升序(可自定义)
2012-10-15 16:04:02
492
原创 括号配对问题 stack 练习
push(x) 入栈pop()出栈top() 访问栈顶empty()判断栈空 为空返回truesize() 栈中的元素个数#include#include#includeusing namespace std;char change( char c ){ return c == ']' ? '[' : '(';}bool match( cha
2012-10-15 15:23:46
234
原创 纪念第一次省赛---Shortest Names
第一次省赛草草结束····留下了无数的遗憾···这在省赛卡到的题目···因为自己比较紧张 把 ‘a’ 打成了 ‘A’ 导致 第一个输入的总是对的 第二次 一样的数据也会错····一直以为是初始化问题···认为指针混乱···总之留下了无数的遗憾···真心对不起自己的队友···下面贴代码····#include#includeusing namespace std;struct N
2012-10-14 20:09:38
597
原创 三角型角平分线与对边的交点
ab/ac = bd/dc 角平分线定理#include#include#includeusing 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
441
原创 凸包+卡壳 最远点对
#include#include#includeusing 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
189
原创 tyvj 多边形统计
#include#include#include#includeusing 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
180
原创 tyvj 放置国王
找对称中心所以x轴对称,y轴对称,分别讨论就可以了···#include#include#includeusing 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
299
原创 hdu 4403 A very hard Aoshu problem
#include#includeusing 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
203
原创 hdu 2200 C(n,m)
#include#includeusing 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
1498
原创 hdu 2108 Shape of HDU 凸包
#include#includeusing 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
437
原创 hdu 2106 decimal system
#include#include#include#includeusing 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
223
原创 hdu 2104 hide handkerchief
/*出现第一个重复点一定会是你自己的位置,因为想到任何一个走过的点就必须先到你走过的点的前一个点,所以第一个出现重复的一定是起点,因为每个点都要走一次,所以总共要走n次m,并且在第n次走到第一个点,那么在第n次之前不存在一个i使得(m*i)% n = 0 也就是n和m的最大公倍数为n*m,也就是n,m互质,所有用辗转相除去解*/#include#includeusing namespa
2012-09-19 19:15:58
250
原创 hdu 2100 Lovekey
#include#include#includeusing 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
166
原创 SBT 营业额统计
size用于维护树的深度,值为自己和孩子的总数;#include#includeusing 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
222
原创 hdu 3987 Harry Potter and the Forbidden Forest
第2道 sap算法练习 #include#includeusing 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
192
原创 hdu 1532 Drainage Ditches
#include#includeusing 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
196
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人