摘要:
变量交换交换变量有很多种方法,一般分为两类,借助第三个变量和不借助第三个变量两种方式.对于ACMer 来说,下面的代码无疑是最优的。1 int main()2 {3 int a , b;4 cin >> a >> b;5 cout 2 3 int main() 4 { 5...
阅读全文
posted @ 2015-05-03 10:43
悠游天地间
阅读(653)
推荐(0)
摘要:
【模板】线段相交 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 struct point 7 { 8 double x,y; 9 };10 point a[105][2];//a[i][0]代...
阅读全文
posted @ 2015-05-03 10:25
悠游天地间
阅读(165)
推荐(0)
摘要:
【模板】高精度计算大数相加: 1 #include 2 #include 3 #include 4 5 void add(char a[],char b[],char back[]) 6 { 7 int i,j,k,up,x,y,z,l; 8 char *c; 9 i...
阅读全文
posted @ 2015-05-03 10:24
悠游天地间
阅读(135)
推荐(0)
摘要:
【模板】快速幂取模 1 long long quickmod(long long a,long long b,long long m) 2 { 3 long long ans = 1; 4 while(b)//用一个循环从右到左便利b的所有二进制位 5 { 6 ...
阅读全文
posted @ 2015-05-03 10:17
悠游天地间
阅读(103)
推荐(0)
摘要:
【模板】二分 1 int binsearch(int *t,int k,int n) 2 { 3 //t为数组,k是要查找的数,n为长度,此为升序 4 5 int low = 1,high = n,mid; 6 7 while(low<=high) 8 { 9 ...
阅读全文
posted @ 2015-05-03 10:15
悠游天地间
阅读(108)
推荐(0)
摘要:
【模板】排序 1 //sort 2 #include 3 bool cmp(const int a,const int b) 4 { 5 return a>b;//降序排列 6 } 7 8 //qsort 9 #include 10 int cmp(const void *x,const ...
阅读全文
posted @ 2015-05-03 10:13
悠游天地间
阅读(77)
推荐(0)
摘要:
【模板】KMP 1 int next[N]; 2 char str1[M],str2[N]; 3 //str1 长,str2 短 4 //len1,len2,对应str1,str2的长 5 6 void get_next(int len2) 7 { 8 int i = 0,...
阅读全文
posted @ 2015-05-03 10:11
悠游天地间
阅读(167)
推荐(0)
摘要:
【模板】并查集 1 int find(int x) 2 { 3 int r = x; 4 while(father[r]!=r) 5 r = father[r]; 6 return r; 7 } 8 /* 9 int find(int x)10 {11 if(...
阅读全文
posted @ 2015-05-03 10:08
悠游天地间
阅读(96)
推荐(0)
摘要:
【模板】各种欧几里得 1 //a > b 2 int gcd(int a , int b) 3 { 4 return b ? gcd( b , a % b ) : a ; 5 } 6 7 int lcm(int a , int b) 8 { 9 return a / gcd( a ...
阅读全文
posted @ 2015-05-03 10:06
悠游天地间
阅读(128)
推荐(0)
摘要:
【模板】素数筛选 1 #include 2 3 int main() 4 { 5 int i,j,a[505]={0}; 6 for(i=1;i<=500;i++) 7 a[i]=1; 8 for(i=2;i<=500;i++) 9 if(...
阅读全文
posted @ 2015-05-03 09:54
悠游天地间
阅读(104)
推荐(0)
摘要:
【模板】BFS 1 #include 2 #include 3 #include 4 using namespace std; 5 6 struct node 7 { 8 int x,y,step; 9 };10 11 char map[105][105];12 int vis[10...
阅读全文
posted @ 2015-05-03 09:52
悠游天地间
阅读(165)
推荐(0)
摘要:
【模板】01背包 1 # include 2 # include 3 # include 4 # define max(x,y) x>y?x:y; 5 int v[1001];//价值 6 int w[1001];//重量 7 int dp[1001][1001]; 8 int main() ...
阅读全文
posted @ 2015-05-03 09:51
悠游天地间
阅读(147)
推荐(0)
摘要:
【模板】计算1的个数 1 __int64 CountOne(__int64 n) 2 { 3 __int64 count =0; 4 if (n ==0) 5 count =0; 6 else if (n >1&& n =10)13 {14 ...
阅读全文
posted @ 2015-05-03 09:50
悠游天地间
阅读(139)
推荐(0)
摘要:
【模板】最长公共子序列 1 #include 2 #include 3 #include 4 using namespace std; 5 6 char s1[1000],s2[1000]; 7 int len1,len2,dp[1000][1000],mark[1000][1000];//...
阅读全文
posted @ 2015-05-03 09:47
悠游天地间
阅读(180)
推荐(0)
摘要:
【模板】最长递增子序列一般情况: 1 #include 2 #include 3 #include 4 using namespace std; 5 6 int a[1005],dp[1005],n; 7 8 int LIS() 9 {10 int i,j,ans,m;11 ...
阅读全文
posted @ 2015-05-03 09:45
悠游天地间
阅读(173)
推荐(0)
摘要:
【模板】最长递增公共子序列二维 1 #include 2 #include 3 #include 4 using namespace std; 5 6 int n,m,a[505],b[505],dp[505][505]; 7 8 int LICS() 9 {10 int MAX,...
阅读全文
posted @ 2015-05-03 09:37
悠游天地间
阅读(167)
推荐(0)
摘要:
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3602Count the TreesTime Limit:2 Seconds Memory Limit:65536 KBA binary tree is a tree data...
阅读全文
posted @ 2015-05-02 22:15
悠游天地间
阅读(191)
推荐(0)
摘要:
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3608Signal DetectionTime Limit:2 Seconds Memory Limit:65536 KBParallelepipedTypePrismFace...
阅读全文
posted @ 2015-05-02 22:10
悠游天地间
阅读(391)
推荐(0)
摘要:
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3606Lazy SalesgirlTime Limit:5 Seconds Memory Limit:65536 KBKochiya Sanae is a lazy girl ...
阅读全文
posted @ 2015-05-02 22:05
悠游天地间
阅读(205)
推荐(0)
摘要:
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3605Find the MarbleTime Limit:2 Seconds Memory Limit:65536 KBAlice and Bob are playing a ...
阅读全文
posted @ 2015-05-02 21:57
悠游天地间
阅读(283)
推荐(0)
摘要:
Prufer数列 Prufer数列是无根树的一种数列。在组合数学中,Prufer数列由有一个对于顶点标过号的树转化来的数列,点数为n的树转化来的Prufer数列长度为n-2。它可以通过简单的迭代方法计算出来。它由Heinz Prufer于1918年在证明cayley定理时首次提出。目录1将树转化成...
阅读全文
posted @ 2015-05-02 21:18
悠游天地间
阅读(915)
推荐(0)
摘要:
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3604Tunnel NetworkTime Limit:2 Seconds Memory Limit:65536 KBCountry Far-Far-Away is a big...
阅读全文
posted @ 2015-05-02 21:14
悠游天地间
阅读(593)
推荐(0)
摘要:
//求gcd(a,b)LLgcd(LLa,LLb){returnb?gcd(b,a%b):a;}//求整数x和y,使得ax+by=d,且|x|+|y|最小。其中d=gcd(a,b)voidgcd(LLa,LLb,LL&d,LL&x,LL&y){if(!b){d=a;x=1;y=0;}else{gcd...
阅读全文
posted @ 2015-05-02 21:11
悠游天地间
阅读(177)
推荐(0)
摘要:
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3601Unrequited LoveTime Limit:16 Seconds Memory Limit:131072 KBThere arensingle boys andm...
阅读全文
posted @ 2015-05-02 17:58
悠游天地间
阅读(198)
推荐(0)
摘要:
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3607Lazier SalesgirlTime Limit:2 Seconds Memory Limit:65536 KBKochiya Sanae is a lazy gir...
阅读全文
posted @ 2015-05-02 17:15
悠游天地间
阅读(191)
推荐(0)
摘要:
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=11141114: 平方根大搜索Time Limit:5 SecMemory Limit:128 MBSubmit:118Solved:60[Submit][Status][Web Board]Desc...
阅读全文
posted @ 2015-05-01 20:05
悠游天地间
阅读(701)
推荐(0)
摘要:
STL容器类的模板容器部分主要由头文件,,,,,和组成。对于常用的一些容器和容器适配器(可以看作由其它容器实现的容器),可以通过下表总结一下它们和相应头文件的对应关系。数据结构描述实现头文件向量(vector)连续存储的元素列表(list)由节点组成的双向链表,每个结点包含着一个元素双队列(dequ...
阅读全文
posted @ 2015-05-01 13:56
悠游天地间
阅读(167)
推荐(0)
摘要:
优先队列用法在优先队列中,优先级高的元素先出队列。标准库默认使用元素类型的qi;通过,greater>qi2;//从小到大的优先级队列可将greater改为less即为从大到小其中 第一个参数为容器类型。 第二个参数为比较函数。故示例2中输出结果为:23569第三种用法: 自定义优先级。struc...
阅读全文
posted @ 2015-05-01 13:48
悠游天地间
阅读(195)
推荐(0)
摘要:
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=15071507: 超大型LED显示屏时间限制:1 Sec内存限制:128 MB 提交:124解决:61 [提交][状态][讨论版]题目描述输入输入包含不超过100组数据。每组数据第一行为"START ...
阅读全文
posted @ 2015-04-30 21:53
悠游天地间
阅读(219)
推荐(0)
摘要:
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=15051505: 酷酷的单词时间限制:1 Sec内存限制:128 MB 提交:340解决:135 [提交][状态][讨论版]题目描述输入一些仅由小写字母组成的单词。你的任务是统计有多少个单词是“酷”的...
阅读全文
posted @ 2015-04-30 21:49
悠游天地间
阅读(204)
推荐(0)
摘要:
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=15031503: 点到圆弧的距离时间限制:1 Sec内存限制:128 MBSpecial Judge 提交:247解决:59 [提交][状态][讨论版]题目描述输入一个点P和一条圆弧(圆周的一部分),...
阅读全文
posted @ 2015-04-30 21:41
悠游天地间
阅读(695)
推荐(0)
摘要:
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=15111511: 残缺的棋盘时间限制:1 Sec内存限制:128 MB题目描述输入输入包含不超过10000 组数据。每组数据包含6个整数r1, c1, r2, c2, r3, c3 (1 2 #inc...
阅读全文
posted @ 2015-04-30 21:23
悠游天地间
阅读(294)
推荐(0)
摘要:
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2151Phone NumberTime Limit: 1000ms Memory limit: 65536K有疑问?点这里^_^题目描述We know th...
阅读全文
posted @ 2015-04-30 11:09
悠游天地间
阅读(179)
推荐(0)
摘要:
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2610Boring CountingTime Limit: 3000ms Memory limit: 65536K有疑问?点这里^_^题目描述 In th...
阅读全文
posted @ 2015-04-30 11:01
悠游天地间
阅读(123)
推荐(0)
摘要:
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2609A-Number and B-NumberTime Limit: 1000ms Memory limit: 65536K有疑问?点这里^_^题目描述 ...
阅读全文
posted @ 2015-04-30 10:55
悠游天地间
阅读(146)
推荐(0)
摘要:
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2624Contest Print ServerTime Limit: 1000ms Memory limit: 65536K有疑问?点这里^_^题目描述 ...
阅读全文
posted @ 2015-04-30 10:39
悠游天地间
阅读(194)
推荐(0)
摘要:
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2608Alice and BobTime Limit: 1000ms Memory limit: 65536K有疑问?点这里^_^题目描述 Alice a...
阅读全文
posted @ 2015-04-30 10:29
悠游天地间
阅读(167)
推荐(0)
摘要:
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2623The number of stepsTime Limit: 1000ms Memory limit: 65536K有疑问?点这里^_^题目描述 M...
阅读全文
posted @ 2015-04-30 10:22
悠游天地间
阅读(160)
推荐(0)
摘要:
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2606Rubik’s cubeTime Limit: 2000ms Memory limit: 65536K有疑问?点这里^_^题目描述 Flabby i...
阅读全文
posted @ 2015-04-30 09:44
悠游天地间
阅读(276)
推荐(0)
摘要:
向量的旋转实际做题中我们可能会遇到很多有关及计算几何的问题,其中有一类问题就是向量的旋转问题,下面我们来具体探讨一下有关旋转的问题。首先我们先把问题简化一下,我们先研究一个点绕另一个点旋转一定角度的问题。已知A点坐标(x1,y1),B点坐标(x2,y2),我们需要求得A点绕着B点旋转θ度后的位置。A...
阅读全文
posted @ 2015-04-30 09:28
悠游天地间
阅读(2266)
推荐(1)