ACM程序设计题1
ACM 1

ACM程序设计大赛ACM程序设计大赛是大学级别最高的脑力竞赛,素来被冠以"程序设计的奥林匹克"的尊称。
大赛自1970年开始至今已有30年历史,是世界范围内历史最悠久、规模最大的程序设计竞赛。
比赛形式是:经过校级和地区级选拔的参赛组,于指定的时间、地点参加世界级的决赛,由3个成员组成的小组应用一台计算机解决6到8个生活中的实际问题。
比赛目的比赛参赛队员必须在5小时内编完程序并进行测试和调试。
此种大赛对参赛学生的逻辑分析能力、策略制定和脑力方面具有极大的挑战性。
大赛提倡在压力较大的情况下,培养学生的创造力、团队合作精神以解决竞赛的问题,从而挑选和发掘世界上最优秀的程序设计人才。
历史竞赛的历史可以上溯到1970年,当时在美国德克萨斯A&M大学举办了首届比赛。
当时的主办方是the Alpha Chapter of the UPE Computer Science Honor Society。
作为一种全新的发现和培养计算机科学顶尖学生的方式,竞赛很快得到美国和加拿大各大学的积极响应。
1977年,在ACM计算机科学会议期间举办了首次总决赛,并演变成为目前的一年一届的多国参与的国际性比赛。
迄今已经举办了29届。
最初几届比赛的参赛队伍主要来自美国和加拿大,后来逐渐发展成为一项世界范围内的竞赛。
特别是自1997年IBM开始赞助赛事之后,赛事规模增长迅速。
1997年,总共有来自560所大学的840支队伍参加比赛。
而到了2004年,这一数字迅速增加到840所大学的4109支队伍并以每年10-20%的速度在增长。
1980年代,ACM将竞赛的总部设在位于美国德克萨斯州的贝勒大学。
在赛事的早期,冠军多为美国和加拿大的大学获得。
而进入1990年代后期以来,俄罗斯和其它一些东欧国家的大学连夺数次冠军。
来自中国大陆的上海交通大学代表队则在2002年美国夏威夷第26届和2005年上海举行的第29届全球总决赛上两夺冠军。
acm程序设计教程 course(1)初识ACM

2011-9-5
38
2009-6-9 讨论湖南省大学生计算机程 序设计竞赛湖南师范大学具体实施方案 2009-6-10 下发2009年湖南省大学生计 算机程序设计竞赛湖南师范大学选拔赛 通知(数计院、物信院、工学院) 2009-6-15 正式选拔 2009-7-4 开学典礼 7-10——8-10 暑假集训
2011-9-5
6
ACM/ICPC in China
中国大陆高校从1996年开始参加ACM/ICPC—— 前六届中国赛区设在上海,由上海大学承办; 2002年由清华大学和西安交通大学承办; 2003年由清华大学和中山大学承办。 2004年由北京大学和上海交通大学承办。 2005年由四川大学、北大和浙大承办。 2006年由上海大学、清华和西电承办。 2007年:北航、南航、吉大、西华 2008年:哈工程、北交、合肥、杭电、西南民大
35
2011-9-5
今年比赛
2011(9.14-9.15) 湖南农业大学
2011-9-5
36
第三部分
我校ACM相关情况
2011-9-5 37
组建过程
Байду номын сангаас
2009-5-7 ACM/ICPC华中南区程序设 计大赛选拔考试(小范围,数计学院) 2009-5-8 组队报名、竞赛介绍、简单 培训 5月29日至5月31日 参加ACM/ICPC华 中南区程序设计大赛(湖南大学)
参赛队组成
ACM-ICPC以团队的形式代表各学校参赛, 每个 赛区的优胜队伍将获得参加ACM国际大学生程序 设计竞赛全球总决赛资格。 亚洲区的高校可以组队参加亚洲的任何一个或者 几个赛区的比赛,但每所高校最多只能有一队可 以获得参加全球世界决赛的资格。 每队由一名教练和三名队员组成, 有些赛区还允许 有一名候补队员。 亚洲区的每位参赛选手在一年内最多可参加两个 赛区的亚洲区预选赛, 每位选手最多可以参加五届 亚洲区预选赛和两届全球总决赛。
大学ACM考试题目及作业答案整理

ACM作业与答案整理1、平面分割方法:设有n条封闭曲线画在平面上,而任何两条封闭曲线恰好相交于两点,且任何三条封闭曲线不相交于同一点,问这些封闭曲线把平面分割成的区域个数。
#include <iostream.h>int f(int n){if(n==1) return 2;else return f(n-1)+2*(n-1);}void main(){int n;while(1){cin>>n;cout<<f(n)<<endl;}}2、LELE的RPG难题:有排成一行的n个方格,用红(Red)、粉(Pink)、绿(Green)三色涂每个格子,每格涂一色,要求任何相邻的方格不能同色,且首尾两格也不同色.编程全部的满足要求的涂法.#include<iostream.h>int f(int n){if(n==1) return 3;else if(n==2) return 6;else return f(n-1)+f(n-2)*2;}void main(){int n;while(1){cin>>n;cout<<f(n)<<endl;}}3、北大ACM(1942)Paths on a GridTime Limit: 1000MS Memory Limit: 30000K DescriptionImagine you are attending your math lesson at school. Once again, you are bored because your teacher tells things that you already mastered years ago (this time he's explaining that (a+b)2=a2+2ab+b2). So you decide to waste your time with drawing modern art instead.Fortunately you have a piece of squared paper and you choose a rectangle of size n*m on the paper. Let's call this rectangle together with the lines it contains a grid. Starting at the lower left corner of the grid, you move your pencil to the upper right corner, taking care that it stays on the lines and moves only to the right or up. The result is shown on the left:Really a masterpiece, isn't it? Repeating the procedure one more time, you arrive with the picture shown on the right. Now you wonder: how many different works of art can you produce?InputThe input contains several testcases. Each is specified by two unsigned 32-bit integers n and m, denoting the size of the rectangle. As you can observe, the number of lines of the corresponding grid is one more in each dimension. Input is terminated by n=m=0.OutputFor each test case output on a line the number of different art works that can be generated using the procedure described above. That is, how many paths are there on a grid where each step of the path consists of moving one unit to the right orone unit up? You may safely assume that this number fits into a 32-bit unsigned integer.Sample Input5 41 10 0Sample Output1262#include<iostream>using namespace std;long long f(long long m, long long n){if(n==0) return 1;else return f(m-1,n-1)*m/n;}int main(){long long m,n;while(scanf("%I64d %I64d",&n,&m) && n+m){printf("%I64d\n",f(m+n,min(m,n)));}return 0;}1、北大ACM(1012)JosephTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 31213 Accepted: 11700 DescriptionThe Joseph's problem is notoriously known. For those who are not familiar with the original problem: from among n people, numbered 1, 2, . . ., n, standing in circle every mth is going to be executed and only the life of the last remaining person will be saved. Joseph was smart enough to choose the position of the last remaining person, thus saving his life to give us the message about the incident. For example when n = 6 and m = 5 then the people will be executed in the order 5, 4, 6, 2, 3 and 1 will be saved.Suppose that there are k good guys and k bad guys. In the circle the first k are good guys and the last k bad guys. You have to determine such minimal m that all the bad guys will be executed before the first good guy.题目大意:编号为1,2…, n的n个人排成一圈,从第一个人开始,去掉后面的第m个人,在从第m+1个人开始去掉后面第m个人,以此类推。
acm程序 循环题目

acm程序循环题目
以下是两道常见的 ACM 循环题目:
1. 水桶挑战赛:一个 n 个人组成的队伍在 m 个水桶中轮流取水,每个人只能取一个水桶的水,且每个水桶的水量不同。
要求每个人取水的总时间不超过 t 分钟。
求出每个人取水的最优策略。
2. 循环赛日程表:给定 n 个队伍,需要安排一场循环赛,每个队伍都要与
其他所有队伍进行一场比赛,并且每个队伍只进行一场比赛。
要求找出一种最优的比赛日程表,使得每个队伍等待的时间最短。
这两道题目都是经典的 ACM 循环题目,考察的是循环和动态规划的思想。
在解决这类问题时,需要注意循环的起点和终点,以及循环中每个状态的含义和转移方程。
同时,还需要注意状态压缩和记忆化搜索等优化技巧的使用。
exercise1_ACM

第一次作业1、平面分割方法设有n条封闭曲线画在平面上,而任何两条封闭曲线恰好相交于两点,且任何三条封闭曲线不相交于同一点,问这些封闭曲线把平面分割成的区域个数。
输入示例:3输出示例:8要求:用两种方法:(1)得到第n项与其之前已知项之间的关系,程序用递归实现(2)得到第n项的通项公式,程序直接实现。
解:每增加一条封闭曲线该曲线就会与之前的每条曲线产生两个交点,所以会增加2(n-1)个交点。
(1)递归关系:f(n)=f(n-1)+2(n-1)(增加几个交点就增加几个平面),f(1)=2 (2)通项公式:f(n)=n(n-1)+2//(1)//平面分割方法int countArea(int n)//递归法{if(n==1)return 2;elsereturn countArea(n-1)+2*(n-1);}//通项公式法an=2+n(n-1)int countArea2(int n){return 2+n*(n-1);}2、LELE的RPG难题有排成一行的n个方格,用红(Red)、粉(Pink)、绿(Green)三色涂每个格子,每格涂一色,要求任何相邻的方格不能同色,且首尾两格也不同色.求全部的满足要求的涂法.输入示例:3输出示例:6解:递归分析:从f(n-1)增加到f(n)分两种情况:(1)一种是直接在所有已经排好了的f(n-1)序列中插入唯一一个第三色有f(n-1)种;(2)另外是在已经排好了的f(n-2)序列中,插入与缝隙两边其中一个颜色相同的颜色,然后再插入第n个颜色且只需与第n-1种颜色不同有两种,故有2f(n-2)种;递归关系:f(n)=f(n-1)+2f(n-2),(n>=2)//(2)LELE的RPG难题int countColor(int n){if(n==2)return 6;else if(n==3)return 6;elsereturn countColor(n-1)+*countColor(n-2);}3、假设一个有序数组A[0], A[1], …, A[N-1],编写一个函数int find(int A[], int x),确定一个整数x是否在数组A中,如果在,则返回其位置,否则返回-1//有序数组元素查找-二分查找int find(int A[],int n){//sizeof(A)sizeof写进函数得不到数组所占的内存数,而仅是一个指针的内存大小 int length=0;//参数数组长度for(int i=0;A[i]!=0;i++){length++;}int left=0,mid,right=length-1;while(left<=right){mid=(left+right)/2;if(n<A[mid])right=mid-1;else if(n>A[mid]){left=mid+1;}elsereturn mid;}return -1;}4、假设数组a中的元素是按从小到大顺序排列的,函数find(int a[], int n, int &i, int &j, int x)利用二分搜索法确定x是否在含有n个元素的数组a中,如果不在,则参数i为小于x的最大元素的下标,参数j为大于x的最小元素的下标。
2.简单计算题(一)

2/38
最小公倍数
• /ShowProblem.aspx ?ShowID=1178 • /showproblem.php? pid=1108
3/38
• Problem Description 求两个正整数的最小公倍数。 • Input 输入数据含有不多于50对的数据,每对数据 由两个正整数(0<n1,n2<100000)组成。 • Output 对于每组数据n1和n1,计算最小公倍数,每 个计算结果应占单独一行。
8/38
POJ 2750 鸡兔同笼
• /problem?id=2750
9/38
• Problem Description
一个笼子里面关了鸡和兔子(鸡有2只脚,兔子有4只脚,没有 例外)。已经知道了笼子里面脚的总数a,问笼子里面至少有多 少只动物,至多有多少只动物。
ACM算法与程序设计
第二讲
简单计算题(一)
简单计算题
• 主要目的:通过编写一些简单计算题的程 序.焘悉C/C++语言的基本语法. • 基本思想:解决简单的计算问题的基本过程包 括将一个用自然语言描述的实际问题抽象成一 个计算问题.给出计算过程.继而编程实现计 算过程,并将计算结果还原成对原来问题的解 答。这里首要的是读懂问题.接清输入和输出 数据的含义及给出的格式· 并且通过输入输出样 例验证自己的理解是否正确。
} return x;
}
7/38
#include<iostream.h> int gcd(int int) ; Int main() { int x,y; while(cin>>x>>y) { cout<<x*y/gcd(x,y)<<end1; cout<<x/gcd(x,y)*y<<end1; } return 0; } int gcd(int a,int b){return !b?a:gcd(b,a%b);}
北大ACM题型

3.C[i,j]=w[i,j]+opt{C[i,k-1]+C[k,j]}.(最优二分检索树问题)
六.数学
(1)组合数学:
1.加法原理和乘法原理.
2.排列组合.
3.递推关系. (POJ3252,poj1850,poj1019,poj1942)
(2)数论.
1.素数与整除问题
(2)扫描线算法(例如求矩形的面积和周长并,常和线段树或堆一起使用). (poj1765,poj1177,poj1151,poj3277,poj2280,poj3004)
(3)多边形的内核(半平面交)(poj3130,poj3335)
(4)几何工具的综合应用.(poj1819,poj1066,poj2043,poj3227,poj2165,poj3429)
(2)记录状态的动态规划. (POJ3254,poj2411,poj1185)
(3)树型动态规划(poj2057,poj1947,poj2486,poj3140)
六.数学
(1)组合数学:
1.容斥原理.
2.抽屉原理.
3.置换群与Polya定理(poj1286,poj2409,poj3270,poj1026).
五.动态规划
(1)需要用数据结构优化的动态规划. (poj2754,poj3378,poj3017)
(2)四边形不等式理论.
(3)较难的状态DP(poj3133)
六.数学
(1)组合数学.
1.MoBius反演(poj2888,poj2154)
2.偏序关系理论.
(2)博奕论.
----------------------------------------------------------------------------------------------- -----------------------------------补充 Dp状态设计与方程总结
acm构造题

acm构造题
当谈到构造题时,有许多不同类型的ACM构造问题。
以下是一些常见的ACM构造题目类型和解决方法:
1.排列组合构造:这类问题通常要求你构造一个满足某种条件的排列或组合。
解决这类问题的关键是理解条件并找到一种满足条件的构造方法。
可以使用递归、迭代或其他数学技巧来解决这类问题。
2.图论构造:这类问题涉及到构建满足某些图论性质的图。
常见的图论构造问题包括树的构造、连通图的构造、二分图的构造等。
解决这类问题通常需要理解图论的基本概念和性质,并使用合适的算法进行构造。
3.数据结构构造:这类问题要求你构造一个满足某种数据结构性质的数据结构。
例如,构造一个满足平衡二叉搜索树性质的树,或者构造一个满足堆性质的数组。
解决这类问题通常需要对特定数据结构的性质和操作进行了解,并设计相应的构造方法。
4.数学构造:这类问题要求你构造一个满足某种数学性质的对象。
例如,构造一组满足特定方程的整数,或者构造一种满足特定性质的数列。
解决这类问题通常需要运用数学知识和技巧,并找到合适的构造方法。
对于ACM构造题目,关键是理解问题的要求和条件,并设计一个满足条件的构造方法。
可以根据问题的性质选择适当的算法、数据结构或数学技巧来解决问题。
在解题过程中,需要注意时间复杂度和空间复杂度的控制,以确保算法的效率和正
确性。
另外,多进行思维训练和练习,熟悉不同类型的构造问题,能够提高解决问题的能力。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
ACM程序设计题目(ENGLISH)
2006-08-08 15:49
A developer has designed a subdivision within a city such that all roads connect at intersections in a treelike design. This is to prevent all petrolhead hooligans from disturbing the residents by not having any road loops for races. Only the entering intersection is connected to the rest of the city. The developer is selling off land alongside roads between adjacent intersections. A real estate agent has produced a book indicating the expected dollar profit (positive, zero or negative) that can be obtained by purchasing the land alongside each road.
Potential buyers want to maximize their profit, but prefer to buy a contiguous stretch of land alongside a simple road chain that connects two intersections of the subdivision. Your task is to write a program to determine the maximum non negative profit that can be obtained this way, and return 0 if no such profit can be obtained.
As an example, consider the following representation of a subdivision, where road labels represent expected profits. In this scenario, the maximum non negative profit is 7, and can be obtained alongside the road chain between the intersections #2 and #5:
Input
Input for this problem consists of a sequence of one or more scenarios. Each scenario contains two or more lines.
The first line contains an integer n , 1n500000 , indicating the number of intersections, including the entrance intersection,
implicitly labelled 0.
This is then followed by one or more lines, containing n - 1 pairs of integers. All integers are separated by single spaces or
newlines. The y -th intersection is defined by the y -th pair of
integers `x p', where 1y< n, 0x< y, -1000p1000 . This pair indicates a road segment between y and a previously defined intersection, x , with a profit value p .(Attention, for this
program, input lines may contain up to 4096 characters each!)
The input will be terminated by a line consisting of one zero (0). This line should not be processed.
Output
Output will be a sequence of lines, one for each input scenario. Each line will contain an integer, indicating the maximum nonnegative profit, over all possible simple road chains connecting two intersections of the subdivision. Write zero (0) if no profit can be obtained.
Sample Input
6
0 -1 1 3 0 2 1 1 1 4
6
0 2 0 1 0 2 0 1 1 1
5
0 1 1 -3 0 -2 1 -2
5
0 -1 1 -3 0 -2 1 -2
10
0 -1 0 -1 0 0 1 3 1 4 2 4 2 2 3
3 3 3
Sample Output
7
5
1。