![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
那些年做过的ACM
文章平均质量分 69
Dai___
这个作者很懒,什么都没留下…
展开
-
10720 Graph Construction(Havel-Hakimi定理 )
有个细节没注意,wa了好多遍,运用 Havel-Hakimi定理 可解Havel-Hakimi定理讲解 http://sbp810050504.blog.51cto.com/2799422/883904#include #include #include using namespace std;const int N = 10000+10;int num[N], n;int原创 2014-02-26 15:25:55 · 740 阅读 · 0 评论 -
Poj 3372 Candy Distribution
http://poj.org/problem?id=3372一群小孩围成一个圈,老师顺时针发糖,分别每间隔0,1, 2, 3, 4……发一颗,问是否每个同学都有糖数论得做法没想出来,打印了前几项看出来得规律,只要n是2^k则输出YES,否则输出NO数论解法:N个人围成一个圈,老师给N个人分糖果.第i次分到的人的编号是f(x) = (x*(x+1)/2)%N,这N个人能不能至少获原创 2014-05-18 23:58:00 · 1227 阅读 · 0 评论 -
POJ 1659 Frogs' Neighborhood(Havel方法)
#include #include #include #include using namespace std;struct Node{ int xu, num;} q[12];int g[12][12];int cmp(Node a, Node b){ return a.num > b.num;}int main(){ int t, i, j,原创 2014-05-18 23:56:56 · 922 阅读 · 0 评论 -
ZOJ 3365
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3365就是给你一个序列,让你改变最少的数使其变成连续递增的数列用b[i] = a[i]-i;会有意想不到的效果b[i]存的就是从b[]开始一次增的的序列代码中if(sum < cnt) { p原创 2013-10-27 15:50:57 · 689 阅读 · 0 评论 -
uva 10229 - Modular Fibonacci
考虑到出现出现取模,打印了几组数据发现有循环节长度为3*(1#include #include using namespace std;int fib[2000000];int main(){ int m,n; while(scanf("%d%d",&n,&m)==2) { if(!m) printf("0\n");原创 2014-02-24 22:45:12 · 618 阅读 · 0 评论 -
HDU 2940 Hex Factorial
题目求N!中有多少个0用16进制高精度模拟想起来一起以前做过的一道题,求末尾有多少个0,不能取0前边的3 4个非零位存下来进行计算,误差太大#include #include #include using namespace std;#define Max 2000int num[Max], pre[Max];void init(){ memset(num,原创 2014-01-17 09:52:19 · 814 阅读 · 0 评论 -
uva 507 Jill Rides Again(最长子串和)
长度相等时去起点小的#include #include #include using namespace std;const int N = 20000+19;int num[N];int main(void){// freopen("1.txt", "r", stdin);// freopen("2.txt", "w", stdout); int kase,原创 2014-02-25 20:59:35 · 766 阅读 · 0 评论 -
poj 3377 Ferry Lanes
河的两岸共有六种点,分别对则六种点进行搜索就行,需要用优先队列优化刚刚做的时候没想到将河两岸的点放到一个数组里,做的太麻烦了,各种错#include #include #include #include #define LL long longusing namespace std;#define N 1000010struct Node{ int id;原创 2014-01-19 08:46:33 · 911 阅读 · 0 评论 -
HDU 1427 速算24点
http://acm.hdu.edu.cn/showproblem.php?pid=1427简单的dfs枚举所有情况就行符号的组合实际上有两种((ab)c)d 和 (ab)(cb) dfs(sum+pos, cur+1, num[cur+1]); dfs(sum-pos, cur+1, num[cur+1]); dfs(sum*pos, cur+1, num原创 2013-10-20 17:23:37 · 1412 阅读 · 0 评论 -
uva 10099 - The Tourist Guide(最大生成树, 最小边最大)
Problem DThe Tourist GuideInput: standard inputOutput: standard output Mr. G. works as a tourist guide. His current assignment is to take some tourists from one city to another. Some two-way原创 2014-03-02 21:10:48 · 936 阅读 · 0 评论 -
10034 - Freckles(最小生成树)
注意输出格式#include #include #include #include using namespace std;const int N = (55 * 99 + 10)*2;int p[N];struct Line{ int s, e; double len;}q[N];double x[N], y[N];double dis(double x原创 2014-02-26 18:50:08 · 675 阅读 · 0 评论 -
uva 571 - Jugs(倒水问题)
题目链接 : http://uva.onlinejudge.org/external/5/571.pdf缺少一个证明过程,明天补上本题只要求给出一个解,不要求最优。所给的两个罐子容量一定互质,因此必然可以倒出从0到大罐容量间的任何整数值。原理是若A,B互质,则最小公倍数为A×B,即不存在一个1 现在的问题就是用AB两个罐子相互倒水来模拟这个数学过程。设小罐容量为A,大罐容量原创 2014-02-23 22:48:54 · 735 阅读 · 0 评论 -
poj 1273Drainage Ditches
最大流#include #include #include using namespace std;const int MAXN=20010;//点数的最大值const int MAXM=880010;//边数的最大值const int INF=0x3f3f3f3f;struct Node{ int from,to,next; int cap;}edge[M原创 2014-03-09 21:26:07 · 760 阅读 · 0 评论 -
Codeforces Round #232 (Div. 2) B.On Corruption and Numbers(整数拆分)
就是从 l 到 r 之间取一些数, 每个数可以取任意次使得其和为nB. On Corruption and Numberstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outp原创 2014-02-27 18:41:57 · 1037 阅读 · 0 评论 -
hdu 2066 一个人的旅行(dijkstra 多个起点和终点)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2066dijkstra函数每执行一次,得到的dis数组存储的是起点s到其他所有点的距离需要执行s次函数,每次函数分别求出到想去的点的距离的最小值#include #include #include using namespace std;const int N = 1200;原创 2014-03-03 21:58:24 · 958 阅读 · 0 评论 -
Poj 3372 Candy Distribution
http://poj.org/problem?id=3372N个人围成一个圈,老师给N个人分糖果.第i次分到的人的编号是f(x) = (x*(x+1)/2)%N,这N个人能不能至少获得1个糖果.易知必然存在i使得f(N - i - 1) = f(N + i) (mod N), 即周期为N,只要判断f(x)能否构成N的完全剩余系,就能得出结果f(x)为N的完全系,原创 2013-10-16 19:57:59 · 691 阅读 · 0 评论 -
Codeforces Round #232 (Div. 2) A.On Segment's Own Points(区间统计)
A. On Segment's Own Points一开始标记点把 [x, y] 标记, 这样是错误的, 因为题目中统计范围的方式是 y - x 所以应当标记[x ,y)#include #include #include using namespace std;int main(void){// freopen("1.txt", "r", stdin); int原创 2014-02-27 16:46:02 · 723 阅读 · 0 评论 -
POJ1562 Oil Deposits(图论入门)
#include #include #include using namespace std;char map[111][111];int n, m;void dfs(int x, int y){ map[x][y] = '*'; if(x-1 >= 0 && map[x-1][y] == '@') dfs(x-1, y); if(x+1 <原创 2014-05-19 19:39:45 · 802 阅读 · 0 评论