
Sgu
文章平均质量分 80
volzkzg
这个作者很懒,什么都没留下…
展开
-
Sgu101
这道题是求一条能够连通所有骨牌的路径,一开始我吧骨牌当作节点,但这样明显是要超时的,后来经过讨论其实可以吧骨牌上的数字当作节点,骨牌当作边,这样做一遍Hierholzer's algorithm,找到一条记录顶点编号的欧拉路径,再从顶点搜索,直到吧边的序号搜索出来即可/* *Name: Domino *LANG: C++ *Source: sgu101 */#incl原创 2012-04-02 08:35:44 · 825 阅读 · 0 评论 -
sgu116
筛法找质数,然后背包一下/* *NAME:Index of super-prime *LANG:C++ *Source:sgu116 */#include #include #include #include #include using namespace std;bool check[10101];int prime[8000];int n,k;struct原创 2012-04-07 08:11:20 · 654 阅读 · 0 评论 -
sgu106
106. The equationtime limit per test: 0.5 sec. memory limit per test: 4096 KBThere is an equation ax + by + c = 0. Given a,b,c,x1,x2,y1,y2 you must determine, how many integer roots of this eq原创 2012-04-05 10:38:17 · 3085 阅读 · 4 评论 -
sgu124
124. Broken linetime limit per test: 0.5 sec. memory limit per test: 4096 KBThere is a closed broken line on a plane with sides parallel to coordinate axes, without self-crossings and self-con原创 2012-04-10 12:55:42 · 650 阅读 · 0 评论 -
sgu223
223. Little Kingstime limit per test: 1 sec.memory limit per test: 65536 KBinput: standardoutput: standardAfter solving nice problems about bishops and rooks, Petya decided that he原创 2012-04-19 21:34:55 · 1758 阅读 · 0 评论 -
sgu131
1131. Hardwood floortime limit per test: 0.5 sec. memory limit per test: 4096 KBThe banquet hall of Computer Scientists' Palace has a rectangular form of the size M x N (11) rectangles原创 2012-04-24 15:04:30 · 1549 阅读 · 1 评论 -
sgu132
132. Another Chocolate Maniactime limit per test: 0.5 sec. memory limit per test: 4096 KBBob really LOVESchocolate. He thinks he never gets enough. Imagine his joy when his parentstold him t原创 2012-04-25 09:18:07 · 1637 阅读 · 1 评论 -
sgu121
121. Bridges paintingtime limit per test: 0.5 sec. memory limit per test: 4096 KBNew Berland consists of N (1£N£100) islands, some of them are connected by bridges. There can be no more than原创 2012-04-25 15:42:27 · 935 阅读 · 0 评论 -
sgu122
122. The booktime limit per test: 0.5 sec. memory limit per test: 4096 KBThere is a group of N (2<=N<=1000) people which are numbered 1 through N, and everyone of them has not less than [ (N原创 2012-04-26 15:42:30 · 2099 阅读 · 0 评论 -
平衡树的练习
关于平衡树的练习,以后关于平衡树的题都放这儿了1、HNOI2002营业额统计:古董题了,题目大意就是维护一个数列,只有一个操作,在数列中插入一个数,计算出数列中与这个数之差的最小绝对值,统计总和。裸的平衡树模板题,方便一点可以用set+lower_boud+upper_bound秒杀,我写了一下splay,速度还凑活2、NOI2004郁闷的出纳员:题目大意是维护一个数列,并且支持5种操原创 2012-05-04 23:53:55 · 4094 阅读 · 0 评论 -
sgu123
。。。。费波拿起数前N项和。/* *NAME:sum *LANG:C++ *Source:sgu123 */#include #include #include #include #include #include #include #include using namespace std;int k;typedef int digit;class bigNum原创 2012-04-06 10:00:33 · 494 阅读 · 0 评论 -
sgu115
日历问题。。。。。#include #include #include #include #include #include #define printIm cout << "Impossible" << endl;using namespace std;bool ka(int i,int j,int w){ if (w>i || w<=j) return true;原创 2012-04-06 09:34:25 · 521 阅读 · 0 评论 -
sgu114
给出X轴正半轴上所有的一些点,并且有权值,要求找到一个点,到这些点的距离*权值最小,小学数学题。。。#include #include #include #include #include #include #include using namespace std;int n;pair city[15100];;long long sum=0,sum1=0;原创 2012-04-06 09:05:12 · 666 阅读 · 0 评论 -
sgu102
这是一道水题,判断两个数是否是质因数就可一了/* *Name:coprimes *LANG: C++ *Source:sgu102 */#include #include #include #include #include #include using namespace std;int ans=1,n;bool check[10001];int gc原创 2012-04-02 11:28:58 · 456 阅读 · 0 评论 -
sgu103
狗题,其实就是很简单的最短路问题的扩展,一开始不明就理的TLE,MLE,WA,蛋碎了一地,后来发现题目说没有路径就输出0,突然醒悟了!/* *Name:Traffic Lights *LANG:C++ *source:sgu103 */#include #include #include #define MAXN 350#define MAXM 15000#define I原创 2012-04-02 22:49:53 · 547 阅读 · 0 评论 -
Sgu105
目测SGU中最水的一题,找到规律就行了/* *NAME:DIV 3 *LANG:C++ *Source:sgu105 */#include using namespace std;int n,ans;int main(){ cin >> n; cout << ((n/3*2)+(n%3==2)) << endl;}原创 2012-04-02 22:52:39 · 453 阅读 · 0 评论 -
Sgu104
花店橱窗问题,不用多说了吧,是人都知道。/* *Name:Little shop of flowers *LANG:C++ *Source:sgu104 */#include #include #define INF -0x7FFFFFFF/2using namespace std;int a[200][200],ff[200][200];int f,v,max=IN原创 2012-04-02 22:51:35 · 602 阅读 · 0 评论 -
sgu107
这就是一道找找规律的题目,只要找出所有9位数的平方的后面9位为987654321的数有几个就可一了。/* *NAME:987654321problem *LANG:C++ *Source:sgu107 */#include #define pZero printf("%d",0)#define rep(i,p) for (int i=0;i<p;++i)using name原创 2012-04-04 11:06:03 · 475 阅读 · 0 评论 -
sgu113
。。。。判断一个数能否由两个质数组成。。。/* *NAME:Nearly prime numbers *LANG:C++ *Source:sgu113 */#include #include #include #include #include using namespace std;int t,n,num,k;int prime[7000];bool check[原创 2012-04-05 16:04:52 · 524 阅读 · 0 评论 -
sgu108
这道题目看似很水,其实巧妙的处理还是很值得学习的。题目大意就是找出一个数,使得这个数不能被某个数S+该数S每一位上的数字的和组成。暴力搜了一下,这样要开一个10^7的判断数组,加上一个100万的答案数组。这样显然是超空间的。对于判断数组我们可以建一个0-63的数组滚动一下,因为7位数,每一位上的和最多=63.对于答案数组,我们可以对于询问进行双关键字排序,最后取出即可原创 2012-04-04 11:36:04 · 847 阅读 · 0 评论 -
sgu112
这就是高精度的应用,最基础的乘法和减法。#include #include #include #include #include #include #include using namespace std;int a,b;string sa,sb;typedef int digit;class bigNum{private: vector a; in原创 2012-04-05 13:55:16 · 619 阅读 · 0 评论 -
sgu111
模拟一下开方的过程,至于如何开方,百度一下,这里不再赘述#include #include #include #include #include #include #include #include #include using namespace std;typedef int digit;class bigNum{public: vector a;原创 2012-04-06 19:56:35 · 712 阅读 · 0 评论 -
sgu174
题目大意就是给你N条线段,然后按照顺序添加线段,求出当添加入第几条线段时,已添加的某些线段组成了一个回路。 题意很好理解,算法也很容易出来,只要在添加某一条线段时,该线段的两个端点在之前就已经相连,那么加入这个线段后,就必然形成了一个回路。 判断这些点的联通性,一个算法呼之欲出,那就是并查集。可以给每个出现过的点一个编号,然后按照这个编号进行并查集即可。 比较恶心的地方就是给这原创 2012-07-24 15:06:46 · 843 阅读 · 0 评论