
ACM
文章平均质量分 77
gemire
这个作者很懒,什么都没留下…
展开
-
天堂里的游戏
天堂里的游戏多年后,每当Noder看到吉普赛人,就会想起那个遥远的下午。Noder躺在草地上漫无目的的张望,二楼的咖啡馆在日光下闪着亮,像是要进化成一颗巨大的咖啡豆。天气稍有些冷,但草还算暖和。不远的地方坐着一个吉普赛姑娘,手里拿着塔罗牌,带着耳机,边上是她的狗。狗看起来有点凶,姑娘却漂亮。Noder开始计算各种搭讪方式的成功概率,然而狗的存在……。奇怪的事情发生了,姑娘自己走了过来,把耳机戴在No原创 2015-06-06 22:00:36 · 949 阅读 · 0 评论 -
2014名校复试机考模拟题 21375:小明的约会
题目链接:http://zju.acmclub.com/index.php?app=problem_title&id=1&problem_id=21375题目描述小明和他的女朋友是两朵奇葩,总是愿意把简单问题搞得很复杂,这不小明刚接到女朋友发来的一条微信:“我们约会吧!3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm原创 2014-03-09 16:51:52 · 1113 阅读 · 0 评论 -
图论模板
Dijkstra+邻接表(HDU 2544 最短路)#include#include#include#include#include#include#include#include#include#includeusing namespace std ;#define pret(a,b) memset(a,b,sizeof(a))const int INF =原创 2014-03-16 22:49:53 · 526 阅读 · 0 评论 -
PAT 1030 Travel Plan (30)
A traveler's map gives the distances between cities along the highways, together with the cost of each highway. Now you are supposed to write a program to help a traveler to decide the shortest path b原创 2014-03-07 11:23:05 · 1278 阅读 · 0 评论 -
2014名校复试机考模拟题 21376:朋友圈
题目链接:http://zju.acmclub.com/index.php?app=problem_title&id=1&problem_id=21376题目描述小明所在的学校有N个学生,形成M个俱乐部。每个俱乐部里的学生有着一定相似的兴趣爱好,形成一个朋友圈。一个学生可以同时属于若干个不同的俱乐部。根据“我的朋友的朋友也是我的朋友”这个推论可以得出,如果A和B是朋原创 2014-03-09 20:26:58 · 1113 阅读 · 0 评论 -
2014名校复试机考模拟题 21373:最爱回文串
题目描述土豪大学的高富帅实验室里有一个回文帝,名叫小明。小明每次看到一个字符串的时候总喜欢看看它是不是回文串,如果这个字符串不是回文串的话,他就会将这个字符串里的字符重新排列,看看能不能构成回文串。现在小明想让你写一个程序来帮助他实现上述过程。输入格式输入包含多组测试数据。每组输入包含一个字符串,长度不超过5,不包含空格等空白符。原创 2014-03-09 16:44:48 · 1052 阅读 · 0 评论 -
POJ 3255 Roadblocks
DescriptionBessie has moved to a small farm and sometimes enjoys returning to visit one of her best friends. She does not want to get to her old home too quickly, because she likes the scenery alo原创 2014-03-09 10:01:15 · 930 阅读 · 0 评论 -
PAT 1025. 反转链表 (25)
给定一个常数K以及一个单链表L,请编写程序将L中每K个结点反转。例如:给定L为1→2→3→4→5→6,K为3,则输出应该为3→2→1→6→5→4;如果K为4,则输出应该为4→3→2→1→5→6,即最后不到K个元素不反转。输入格式:每个输入包含1个测试用例。每个测试用例第1行给出第1个结点的地址、结点总个数正整数N(5)、以及正整数K(接下来有N行,每行格式为:Add原创 2014-03-08 10:21:45 · 6160 阅读 · 3 评论 -
PAT(Basic Level) 1022 D进制的A+B (20)
输入两个非负10进制整数A和B(30-1),输出A+B的D (1 输入格式:输入在一行中依次给出3个整数A、B和D。输出格式:输出A+B的D进制数。输入样例:123 456 8输出样例:1033注意:有一个case是0和0,如果不注意的话,这个测试点就很难过去。代码如下:#include#include#include#i原创 2014-03-07 16:41:39 · 1847 阅读 · 0 评论 -
POJ 1789 Truck History
DescriptionAdvanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are used for vegetable delivery, other for furniture, or for bricks. The company has its own code describing ea原创 2014-03-08 15:53:34 · 608 阅读 · 0 评论 -
PAT Basic Level 1024. 科学计数法 (20)
科学计数法是科学家用来表示很大或很小的数字的一种方便的方法,其满足正则表达式[+-][1-9]"."[0-9]+E[+-][0-9]+,即数字的整数部分只有1位,小数部分至少有1位,该数字及其指数部分的正负号即使对正数也必定明确给出。现以科学计数法的格式给出实数A,请编写程序按普通数字表示法输出A,并保证所有有效位都被保留。输入格式:每个输入包含1个测试用例,即一个以科学计原创 2014-03-07 20:41:42 · 1736 阅读 · 0 评论 -
PAT 1023. 组个最小数 (20)
给定数字0-9各若干个。你可以以任意顺序排列这些数字,但必须全部使用。目标是使得最后得到的数尽可能小(注意0不能做首位)。例如:给定两个0,两个1,三个5,一个8,我们得到的最小的数就是10015558。现给定数字,请编写程序输出能够组成的最小的数。输入格式:每个输入包含1个测试用例。每个测试用例在一行中给出10个非负整数,顺序表示我们拥有数字0、数字1、……数字9的个数。原创 2014-03-07 18:09:56 · 2802 阅读 · 0 评论 -
PATA 1073. Scientific Notation (20)
Scientific notation is the way that scientists easily handle very large numbers or very small numbers. The notation matches the regular expression [+-][1-9]"."[0-9]+E[+-][0-9]+ which means that the in原创 2014-03-08 13:20:55 · 1000 阅读 · 0 评论 -
PAT Basic Level 1021. 个位数统计 (15)
给定一个k位整数N = dk-1*10k-1 + ... + d1*101 + d0 (0i<=9, i=0,...,k-1, dk-1>0),请编写程序统计每种不同的个位数字出现的次数。例如:给定N = 100311,则有2个0,3个1,和1个3。输入格式:每个输入包含1个测试用例,即一个不超过1000位的正整数N。输出格式:对N中每一种不同的个位数字,以D:原创 2014-03-08 10:37:52 · 1639 阅读 · 0 评论 -
POJ 1258 Agri-Net
DescriptionFarmer John has been elected mayor of his town! One of his campaign promises was to bring internet connectivity to all farms in the area. He needs your help, of course. Farmer John or原创 2014-03-08 14:45:10 · 603 阅读 · 0 评论 -
POJ 1502 MPI Maelstrom
DescriptionBIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed shared memory machine with a hierarchical communication subsystem. Valentine McKee'原创 2014-03-06 19:21:37 · 904 阅读 · 0 评论 -
2014年天勤计算机考研复试上机练习赛(2):世界杯来了
题目描述2014年是世界杯年,小明作为一个资深球迷必然不会错过这场足球界的饕餮盛宴。但是由于比赛太多,而且并不是任何时间小明都能够看球赛,所以小明把他重点关注的那些球赛的转播时间表给你,希望你能够帮他合理安排一下,让他能够尽量多的看到完整的球赛。输入格式输入包含多组测试数据,每组输入的第一行是一个整数n(n接下来n行,每行输入两个整数si原创 2014-03-15 20:39:24 · 1651 阅读 · 0 评论 -
九度1448:Legal or Not
题目描述:ACM-DIY is a large QQ group where many excellent acmers get together. It is so harmonious that just like a big family. Every day,many "holy cows" like HH, hh, AC, ZT, lcc, BF, Qinz and so on原创 2014-03-16 19:57:29 · 616 阅读 · 0 评论 -
九度1449:确定比赛名次(拓扑排序)
题目描述:有N个比赛队(1输入:输入有若干组,每组中的第一行为二个数N(1输出:给出一个符合要求的排名。输出时队伍号之间有空格,最后一名后面没有空格。其他说明:符合条件的排名可能不是唯一的,此时要求输出时编号小的队伍在前;输入数据保证是正确的,即输入数据确保一定能有一个符合要求的排名。样例输入:4 31 22 34 3原创 2014-03-16 20:24:44 · 1202 阅读 · 0 评论 -
Fibonacci数列
在正常情况下,考虑到编程规范,我们可以这样写Fibbonacci:#include#include#include#include#include#includeusing namespace std;const vector* fibon_seq(int);bool fibon_elem(int, long long int&);int main(){ int p原创 2014-02-16 00:28:14 · 695 阅读 · 0 评论 -
浙大2012上机 PAT1034. Head of a Gang (30)
One way that the police finds the head of a gang is to check people's phone calls. If there is a phone call between A and B, we say that A and B is related. The weight of a relation is defined to be t原创 2014-03-22 13:49:33 · 1755 阅读 · 0 评论 -
浙大2012上机 PAT 1031. Hello World for U (20)
Given any string of N (>=5) characters, you are asked to form the characters into the shape of U. For example, "helloworld" can be printed as:h de ll rlowoThat is, the characters must be pr原创 2014-03-22 10:49:12 · 713 阅读 · 0 评论 -
浙大2012上机 PAT 1032. Sharing (25)
To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suffix. For example,原创 2014-03-22 10:09:44 · 833 阅读 · 0 评论 -
浙大2013复试:PAT 1057. Stack (30)
Stack is one of the most fundamental data structures, which is based on the principle of Last In First Out (LIFO). The basic operations include Push (inserting an element onto the top position) and Po原创 2014-03-20 20:18:16 · 3092 阅读 · 0 评论 -
浙大2012上机 PAT 1033. To Fill or Not to Fill (25)
With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Different ga原创 2014-03-22 09:32:53 · 819 阅读 · 0 评论 -
POJ 2299 Ultra-QuickSort(树状数组+离散化处理)
DescriptionIn this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping two adjacent sequence elements until the seque原创 2014-03-20 18:49:09 · 586 阅读 · 0 评论 -
HDOJ 11166 敌兵布阵(树状数组)
Problem DescriptionC国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视原创 2014-03-20 15:38:46 · 755 阅读 · 0 评论 -
HDOJ 1556 Color the ball
Problem DescriptionN个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a Input每个测试实例第一行为一个整数N,(N 当N = 0,输入结束。 Output每个测试实例输出一行,包括N个整数,第I个数代表第I个气球总共被涂色的次数。 Sample Inpu原创 2014-03-20 15:02:15 · 521 阅读 · 0 评论 -
浙大2013复试:PAT 1056. Mice and Rice (25)
Mice and Rice is the name of a programming contest in which each programmer must write a piece of code to control the movements of a mouse in a given map. The goal of each mouse is to eat as much rice原创 2014-03-19 21:41:55 · 2714 阅读 · 1 评论 -
浙大2013复试:PAT 1055 The World's Richest (25)
Forbes magazine publishes every year its list of billionaires based on the annual ranking of the world's wealthiest people. Now you are supposed to simulate this job, but concentrate only on the peopl原创 2014-03-19 20:56:06 · 1355 阅读 · 0 评论 -
PAT 1053. Path of Equal Weight (30)
Given a non-empty tree with root R, and with weight Wi assigned to each tree node Ti. The weight of a path from R to L is defined to be the sum of the weights of all the nodes along the path from R原创 2014-03-19 18:49:49 · 556 阅读 · 0 评论 -
清华2006年复试上机题:二叉树遍历
题目描述:二叉树的前序、中序、后序遍历的定义:前序遍历:对任一子树,先访问跟,然后遍历其左子树,最后遍历其右子树;中序遍历:对任一子树,先遍历其左子树,然后访问根,最后遍历其右子树;后序遍历:对任一子树,先遍历其左子树,然后遍历其右子树,最后访问根。给定一棵二叉树的前序遍历和中序遍历,求其后序遍历(提示:给定前序遍历与中序遍历能够唯一确定后序遍历)。输入:原创 2014-03-19 11:15:40 · 922 阅读 · 0 评论 -
PATA 1020 Tree Traversals (25)
Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level order traversal sequence of the cor原创 2014-03-19 15:20:39 · 634 阅读 · 0 评论 -
中缀表达式转换为后缀表达式
在做计算器时,如果想要中缀表达式:A+B*(C-D)-E/F的值,不妨先转换为相应的后缀表达式为: ABCD-*+EF/-,再利用栈来计算,可能会方便很多。中缀表达式转换为后缀表达式的代码如下:#include #include #include using namespace std;int prior(char op){ if (op == '+' || op ==原创 2014-03-18 15:11:12 · 1372 阅读 · 0 评论 -
POJ 1182 食物链(经典并查集)
Description动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。 有人用两种说法对这N个动物所构成的食物链关系进行描述: 第一种说法是"1 X Y",表示X和Y是同类。 第二种说法是"2 X Y",表示X吃Y。 此人对N个动物原创 2014-03-05 20:27:26 · 7634 阅读 · 2 评论 -
POJ 1611 The Suspects(并查集)
DescriptionSevere acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a global threat in mid-March 2003. To minimize transmission to others, the best s原创 2014-03-05 20:18:30 · 570 阅读 · 0 评论 -
POJ 2524 Ubiquitous Religions(并查集)
DescriptionThere are so many different religions in the world today that it is difficult to keep track of them all. You are interested in finding out how many different religions students in your原创 2014-03-05 21:14:32 · 664 阅读 · 0 评论 -
排序字符串
Problem Description:很多字串,有些是对称的,有些是不对称的,请将那些对称的字串按从小到大的顺序输出。字串先以长度论大小,如果长度相同,再以ASCII码值为大小标准。Input:输入数据中含有一些字串(1≤串长≤256)Output:根据每个字串,输出对称的那些串,并且要求按从小到大的顺序输出。Sample Input:原创 2014-02-19 11:42:35 · 843 阅读 · 0 评论 -
ACM中的一些基础题
一、判断一个数是否为对称三位数素数素数是指只能被1和本身整除的自然数(1不是素数)。关键是判断一个数是否为素数。bool isPrime(int);int main(){ #ifdef ONLINE_JUDGE #else freopen("D:\\in.txt", "r", stdin); freopen("D:\\out.txt",原创 2014-02-18 11:41:24 · 942 阅读 · 0 评论 -
01串排序
Description:将01串首先按长度排序,长度相同时,按1的个数多少进行排序,1的个数相同时再按ASCII码值排序。 Input:输入数据中含有一些01串,01串的长度不大于256个字符。OutPut:重新排列01串的顺序。使得串按基本描述的方式排序。Sample Input:10011111000011011010101101100Sam原创 2014-02-19 10:55:02 · 2214 阅读 · 0 评论