- 博客(12)
- 收藏
- 关注
原创 Vijos P1033 家族
~~~题目链接~~~ 水果~ #include #define N 5002 using namespace std; int n = 0, m = 0, p = 0, father[N], rank[N]; int find(int x) { if(father[x] != x) father[x] = find(father[x])
2012-09-28 22:16:55 530
原创 POJ 2104 K-th Number (划分树)
~~~题目链接~~~ 题目大意:给出n个数,现在要求求出区间中的第k大值 思路:划分树模版 #include #include #define N 100002 using namespace std; struct node { int num[N], val[N]; }t[1000];//记录每层的划分 int n = 0, m = 0, a
2012-09-28 20:06:51 1484
原创 HDOJ 4054 Hexadecimal View
~~~题目链接~~~ 思路:模拟 #include #include int len = 0; char str[5002]; void print(int cur) { int i = 0, j = 0; for(i = cur; i<cur+16; i++) { if(j == 2) printf(" "), j = 0;
2012-09-25 19:15:21 416
原创 UVa 442 Matrix Chain Multiplication
~~~题目链接~~~ 题目大意:给出一些矩阵,现在给出一个带括号的表达式, 要求求出这些矩阵相乘最后得多少 思路:用stack模拟,从表达式的右边开始入栈, 当不是左括号是入栈, 是左括号时表达式出栈,直到遇到右括号。 #include #include #include using namespace std; struct node {
2012-09-24 15:33:36 434
原创 UVa 127 "Accordian" Patience
~~~题目链接~~~ 题目大意:现在有52张牌, 从牌顶开始发牌,发的牌从左到右一张一张的铺好, 当发的当前这张牌与左边第一张或左边第三张牌花色或点数相同时,发的这张牌移动到左边第一张或左边第三张上面(这时成了一个堆), 如果这张牌移动过后又与左边第一张或第三张花色或点数相同就在继续移动。当有多张牌可以移动时, 先移动左边的。当一张牌即可以移动到左边第三张和第一张上时, 移动到左
2012-09-24 15:20:36 505
原创 HDOJ 4119 Isabella's Message
~~~题目链接~~~ 题目大意:给出一个N*N的矩阵,上面有些空格写有字母有些为空格, 现在给你一张N*N解密的卡片(卡片上面有N*N/4个洞),现在把卡片放在有字的矩阵上(初始方向不定),通过洞可以看到字母, 然后旋转卡片90度,又可以看见新的字母(直到旋转3次停止旋转), 现在要求你解密出密文。 思路:模拟............. #include #
2012-09-23 20:15:13 840
原创 HDOJ 1262 寻找素数对
~~~题目链接~~~ 水过 #include #include int main() { int i = 0, j = 0, sum = 0, p[10002] = {0}; p[0] = p[1] = 0; for(i = 2; i<10002; i++) if(i%2) p[i] = 1; else p[i] =
2012-09-13 18:54:41 388
原创 POJ 2389 Bull Math
~~~题目链接~~~ 大数乘法 #include #include int main() { int i = 0, j = 0, len = 0, len1 = 0, len2 = 0, n1[252], n2[252], n3[505]; char s1[252], s2[252]; while(scanf("%s %s", s1, s2)
2012-09-12 13:28:33 329
原创 HDOJ 1002 A + B Problem II
~~~题目链接~~~ #include #include int main() { int i = 0, t = 0, c = 0, len = 0, len1 = 0, len2 = 0, cas = 0; char str1[1002], str2[1002]; int num1[1002], num2[1002]; scanf("%d
2012-09-11 13:40:55 1137
原创 HDOJ 1753 大明A+B
~~~题目链接~~~ #include #include int main() { int i = 0, j = 0, k = 0, p1 = 0, p2 = 0, n = 0, c = 0, len1 = 0, len2 = 0; int l = 0, r = 0; int num1[402], num2[402], num3[402], num
2012-09-10 15:26:26 720
原创 POJ 1511 Invitation Cards (spfa||堆优化)
~~~题目链接~~~ 题目大意:给出一个有向图, 现在又一些人(数量和停车站的数量相同)要到停车站发传单, 它们发完传单后又要乘公交车返回起点1,要求求他们去时和回来时的花费总额最小为多少 spfa #include #include using namespace std; struct node { int v, c, next; }edge[2*1000
2012-09-06 15:10:34 398
原创 POJ 3463 Sightseeing (第k短路)
~~题目链接~~~ 题目大意:给出一个旅游路线,现在要求求它的最短路和比最短路长1的路共有多少条。 思路:看代码吧 #include #include #define inf 1234567890 using namespace std; struct node { int v, w, next; }edge[10002]; struct node2 {
2012-09-05 13:49:38 1278
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人