文档库 最新最全的文档下载
当前位置:文档库 › acm程序设计大赛题目

acm程序设计大赛题目

acm程序设计大赛题目
acm程序设计大赛题目

The Mailboxes Manufacturers Problem

Time Limit:1000MS Memory Limit:65536K

Total Submit:299 Accepted:227

Description

In the good old days when Swedish children were still allowed to blowup their fingers with fire-crackers, gangs of excited kids would plague certain smaller cities during Easter time, with only one thing in mind: To blow things up. Small boxes were easy

to blow up, and thus mailboxes became a popular target. Now, a small mailbox manufacturer is interested in how many fire-crackers his new mailbox prototype can withstand without exploding and has hired you to help him. He will provide you with k(1 ≤ k≤ 10) identical mailbox prototypes each fitting up to m(1 ≤ m≤ 100) crackers. However, he is not sure of how many firecrackers he needs to provide you with in order for you to be able to solve his problem, so he asks you. You think for a while and then say, “Well,if I blow up a mailbox I can’t use it again, so if you would provide me with only k = 1 mailboxes, I would have to start testing with 1 cracker, then 2 crackers, and so on until it finally exploded. In the worst case, that is if it does not blow up ev en when filled with m crackers, I would need 1 + 2 + 3 + … + m = m ×(m+ 1) ? 2 crackers. If m = 100 that would mean more than 5000 fire-crackers!” “That’s too many,” he replies. “What if I give you more than k = 1 mailboxes? Can you find a strategy that requires less crackers?”

Can you? And what is the minimum number of crackers that you should ask him to provide you with?

You may assume the following:

1.If a mailbox can withstand x fire-crackers, it can also withstand x? 1

fire-crackers.

2.Upon an explosion, a mailbox is either totally destroyed (blown up) or

unharmed, which means that it can be reused in another test explosion.

Note: If the mailbox can withstand a full load of m fire-crackers, then the manufacturer will of course be satisfied with that answer. But otherwise he is looking for the maximum number of crackers that his mailboxes can withstand.

Input

The input starts with a single integer N(1 ≤ N≤ 10) indicating the number of test cases to follow. Each test case is described by a line containing two integers: k and m, separated by a single space.

Output

For each test case print one line with a single integer indicating the minimum number of fire-crackers that is needed, in the worst case, in order to figure out how many crackers the mailbox prototype can withstand.

Sample Input

4

1 10

1 100

3 73

5 100

Sample Output

55

5050

382

495

Source

Svenskt M?sterskap i Programmering/Norgesmesterskapet 2002 #include

using namespace std;

const int INF = 1 << 28;

int d[11][101][101];

int sum(int i, int j) {

int ret = 0, k;

for (k=i; k<=j; k++) ret += k;

return ret;

}

int max(int a, int b) {

return a > b ? a : b;

}

int main() {

int caseTime;

int i, j, k, t, K, M, l;

scanf("%d", &caseTime);

while (caseTime--) {

scanf("%d%d", &K, &M);

for (i=1; i<=M; i++) {

for (j=i; j<=M; j++) {

d[1][i][j] = sum(i, j);

}

}

for (k=2; k<=K; k++) {

for (l=0; l

for (i=1; i+l<=M; i++) {

j = i + l;

if (i == j) {

d[k][i][j] = i;

continue;

}

d[k][i][j] = INF;

for (t=i; t<=j; t++) {

int tmp;

if (t == i) tmp = d[k][i+1][j];

else if (t == j) tmp = d[k-1][i][j-1];

else tmp = max(d[k-1][i][t-1], d[k-1][t+1][j]); tmp = max(d[k-1][i][t-1], d[k][t+1][j]);

if (d[k][i][j] > t + tmp) d[k][i][j] = t + tmp; }

}

}

}

printf("%d\n", d[K][1][M]);

}

return 0;

}

Bugs Integrated, Inc.

Time Limit:15000MS Memory

Limit:30000K

Total Submit:1180 Accepted:309 Case Time Limit:5000MS

Description

Bugs Integrated, Inc. is a major manufacturer of advanced memory chips. They are launching production of a new six terabyte Q-RAM chip. Each chip consists of six unit squares arranged in a form of a 2*3 rectangle. The way Q-RAM chips are made is such that one takes a rectangular plate of silicon divided into N*M unit squares. Then all squares are tested carefully and the bad ones are marked with a black marker.

Finally, the plate of silicon is cut into memory chips. Each chip consists of 2*3 (or 3*2) unit squares. Of course, no chip can contain any bad (marked) squares. It might not be possible to cut the plate so that every good unit square is a part of

some memory chip. The corporation wants to waste as little good squares as possible. Therefore they would like to know how to cut the plate to make the maximum number of chips possible.

Task

You are given the dimensions of several silicon plates and a list of all bad unit squares for each plate. Your task is to write a program that computes for each plate the maximum number of chips that can be cut out of the plate.

Input

The first line of the input file consists of a single integer D (1 <= D <= 5), denoting the number of silicon plates. D blocks follow, each describing one silicon plate. The first line of each block contains three integers N (1 <= N <= 150), M (1 <= M <= 10), K (0 <= K <= MN) separated by single spaces. N is the length of the plate, M is its height and K is the number of bad squares in the plate. The following K lines contain a list of bad squares. Each line consists of two integers x and y (1 <= x <= N, 1 <= y <= M) ?coordinates of one bad square (the upper left square has coordinates [1, 1], the bottom right is [N,M]).

Output

For each plate in the input file output a single line containing the maximum number of memory chips that can be cut out of the plate.

Sample Input

2

6 6 5

1 4

4 6

2 2

3 6

6 4

6 5 4

3 3

6 1

6 2

6 4

Sample Output

3

4

Source

CEOI 2002

CODE:

#include

using namespace std;

int g[150][10], blk[10];

int d[4][60000];

int e[11] = {1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049};

int n, m, kn;

int can1, can2, b[10][60000];

int *l0, *l1, *l2, *l3, *bit0, *bit1, *bit2;

void build() {

int i, j, tmp;

for (i=0; i

j = 0; tmp = i;

while (tmp > 0) {

b[j][i] = tmp % 3;

tmp /= 3;

j++;

}

}

}

inline int maxt(int a, int b) {

return a > b ? a : b;

}

void solve() {

int i, j, k, x, y, a1, a2, p, c;

scanf("%d%d%d", &n, &m, &kn);

memset(g, 0, sizeof(g));

memset(d, 0, sizeof(d));

for (i=0; i

scanf("%d%d", &x, &y);

g[x-1][y-1] = 1;

}

for (i=0; i

for (i=1, c=2; i

for (j=0; j

if (g[i][j]) blk[j] = 0;

else blk[j]++;

c = (c+1)%4;

can1 = (j>0 && blk[j]>2 && blk[j-1]>2);

can2 = (j>1 && blk[j]>1 && blk[j-1]>1 && blk[j-2]>1);

a1 = 2*e[j]+2*e[j-1];

a2 = e[j]+e[j-1]+e[j-2];

l0 = d[c]; l1 = d[(c+3)%4]; l2 = d[(c+2)%4]; l3 = d[(c+1)%4];

bit0 = b[j];

if (j>0) bit1 = b[j-1];

if (j>1) bit2 = b[j-2];

for (p=0; p

if (bit0[p]) {

l0[p] = l1[p-e[j]];

} else {

l0[p] = l1[p];

if (j>0 && !bit1[p]) {

if (can1) l0[p] = maxt(l0[p],l2[p+a1]+1);

if (can2 && !bit2[p]) l0[p] = maxt(l0[p], l3[p+a2]+1); }

}

}

}

}

printf("%d\n", d[c][0]);

}

int main() {

build();

int caseTime;

scanf("%d", &caseTime);

while (caseTime--) {

solve();

}

return 0;

}

Silver Cow Party

Time Limit:2000MS Memory

Limit:65536K

Total Submit:1112 Accepted:326 Description

One cow from each of N farms (1 ≤ N≤ 1000) conveniently numbered 1..N is going to attend the big cow party to be held at farm #X(1 ≤ X≤ N). A total of M (1 ≤ M≤ 100,000) unidirectional (one-way roads connects pairs of farms; road i requires T i(1 ≤ T i≤ 100) units of time to traverse.

Each cow must walk to the party and, when the party is over, return to her farm. Each cow is lazy and thus picks an optimal route with the shortest time. A cow's return route might be different from her original route to the party since roads are one-way.

Of all the cows, what is the longest amount of time a cow must spend walking to the party and back?

Line 1: Three space-separated integers, respectively: N, M, and X

Lines 2..M+1: Line i+1 describes road i with three space-separated integers: A i, B i, and T i. The described road runs from farm A i to farm B i, requiring T i time units to traverse.

Output

Line 1: One integer: the maximum of time any one cow must walk.

Sample Input

4 8 2

1 2 4

1 3 2

1 4 7

2 1 1

2 3 5

3 1 2

3 4 4

4 2 3

Sample Output

10

Hint

Cow 4 proceeds directly to the party (3 units) and returns via farms 1 and 3 (7 units), for a total of 10 time units.

USACO 2007 February Silver

#include

using namespace std;

const int INF = 1 << 28;

int adj[1001][1001], adjw[1001][1001], na[1001];

int n, m, x;

//heap sink,swim,getmin,insert参数均为外部编号,wt为其权值int heap[100001], id[100001], hsize;

int *key;

void init(int s, int *wt) {

int i;

hsize = s;

key = wt;

for (i=1; i<=hsize; i++) {

heap[i] = i;

id[i] = i;

}

}

void swim(int u) {

int p = id[u], q = p >> 1, ku = key[u];

while (q && ku < key[heap[q]]) {

id[heap[q]] = p;

heap[p] = heap[q];

p = q;

q = p >> 1;

}

id[u] = p;

heap[p] = u;

}

void sink(int u) {

int p = id[u],q = p << 1, ku = key[u];

while (q <= hsize) {

if (q < hsize && key[heap[q+1]] < key[heap[q]]) q++;

if (key[heap[q]] >= ku) break;

id[heap[q]] = p;

heap[p] = heap[q];

p = q;

q = p << 1;

}

id[u] = p;

heap[p] = u;

}

int getmin() {

int ret = heap[1];

id[ret] = -1;

id[heap[hsize]] = 1;

heap[1] = heap[hsize];

hsize--;

sink(heap[1]);

return ret;

}

void insert(int u) {

heap[++hsize] = u;

id[u] = hsize;

swim(u);

}

void build() {

int i;

for (i=hsize/2; i>0; i--) sink(heap[i]); }

bool isEmpty() {

return hsize == 0;

}

int dijkstraHeap(int beg, int end=-1) {

int i, j, k, u, v, w;

int dist[1001], chk[1001];

for (i=1; i<=n; i++) {

dist[i] = INF;

chk[i] = 0;

}

init(n, dist);

dist[beg] = 0; swim(beg);

while (!isEmpty()) {

u = getmin();

if (u == end) break;

chk[u] = 1;

for (i=0; i

v = adj[u][i];

w = adjw[u][i];

if (dist[v] > dist[u] + w) { dist[v] = dist[u] + w;

swim(v);

}

}

}

if (end == -1) return dist[n];

return dist[end];

}

int main() {

int i, j, k, u, v, w;

int val[1001];

scanf("%d%d%d", &n, &m, &x);

for (i=0; i

scanf("%d%d%d", &u, &v, &w);

adj[u][na[u]] = v;

adjw[u][na[u]] = w;

na[u]++;

}

dijkstraHeap(x);

memcpy(val, key, sizeof(val));

int ans = 0;

for (i=1; i<=n; i++) {

int tmp = dijkstraHeap(i,x);

if (tmp+val[i] > ans) ans = tmp + val[i]; }

printf("%d\n", ans);

return 0;

}

安徽ACM省赛试题

2018年安徽省机器人大赛程序设计竞赛

目录A.数7 B.编译错误 C.做操的时候要排好队D.判重 E.最长上升字串 F.雄伟的城堡 G.然后打5 H.运货卡车 I.最大矩形框 J.数列分段 K.数数字

A.数7 时间限制: 3s 描述 求整数序列中位置L到位置R中一共有多少个7。对于每个数7的个数的定义为,十进制各个位置上一共有多少个7,以及能够被7整除的次数。 输入 第一行是一个整数T,代表测试数据的组数。每组数据中两个整数L,R。其中T≤50,L

B.编译错误 时间限制: 3s 描述 在程序员编写程序的时候,通常会引用其他文件,而引用的文件也会引用其它的头文件。但是出现循环引用的现象编译时便会报错。例如A引用了B,B引用了C,C引用了A,那么就产生了循环引用(Circular reference)。考虑另外一个情况,A引用了B和C,B引用D,C引用D,虽然D被引用了两次,但是没有出现循环引用。 输入 第一行是一个整数T,代表测试数据的组数。每组数据中第一行是一个整数n,代表有多少个引用关系。接下来n行每行有2个字符串a,b,用空格分隔,代表a引用了b。其中T≤50, n≤105,每个字符串长度不超过100。 输出 共T行。若不会产生编译错误则输出Passed,否则输出Failed。 样例输入 样例输出

C.做操的时候要排好队 时间限制: 3s 描述 同学们在做早操时,应该按照身高从低到高排好队。但是总是有人不好好排队,老师在审查时会对没有排好的队伍扣除一定的分数。扣的分数被定义为,找到三个人Ai,Aj,Ak,其中i

ACM题目整理

题目来源:福州大学acm网站 代码:fpcdq 一、入门 熟悉ACM竞赛规则以及程序提交注意事项 例题: Problem 1000 A+B Problem Time Limit: 1000 mSec Memory Limit : 32768 KB Problem Description Calculate a + b. Input The input will consist of a series of pairs of integers a and b,separated by a space, one pair of integers per line. Output For each pair of input integers a and b you should output the sum of a and b in one line,and with one line of output for each line in input. Sample Input 1 5 2 3 Sample Output 6 5

My answer: #include main() { long a,b; while((scanf("%ld%ld",&a,&b))!=EOF) { printf("%ld\n",a+b); } } 详情参考https://www.wendangku.net/doc/1113180970.html,/faq.php 二、ACM分类 主流算法: 1.搜索//回溯 Problem 1019 猫捉老鼠 Time Limit: 1000 mSec Memory Limit : 32768 KB Problem Description 一只猫和一只老鼠在10*10的迷宫中。迷宫中的每个方格可以是空的,或者含有障碍。猫和老鼠可以进入任意一个空的方格中。当他们相遇时,猫和老鼠在同一个方格中。但是,无论猫或老鼠都不能进入有障碍的方格。我们可以用字符组成的二维数组表示迷宫,如下图所示。

山东科技大学第二届ACM程序设计大赛试题

山东科技大学 第二届ACM程序设计大赛 试题册 试题共14页,题目共计12道

山东科技大学第二届ACM 程序设计大赛试题册 Problem A 简单计算 Description 给出n 个十进制的数,找出这n 个数的二进制表示中1的个数最少的数。 Input 输入的第一行为一个正整数T (1≤T ≤20),代表测试数据组数。 对于每组测试数据,输入的第一行为一个正整数n (1≤n ≤10000),第二行为n 个正整数A 1、A 2、…、A n (1≤A i ≤109 ),每个数之间以空格分隔。 Output 每组数据输出一行,先输出数据组数,再输出二进制中含1最少的数,如果存在多个数符合条件,输出最小的那个。具体输出格式见样例输出。 Sample Input Sample Output

山东科技大学第二届ACM 程序设计大赛试题册 Problem B 关键字搜索 Description 我们的新网站具有了全新的搜索功能,使用了2个通配符“*”和“?”,其中“*”表示0或者多个小写字母,“?”代表1个字母。 当我们输入一个关键字的时候,我们在不确定的地方就使用通配符。我们在数据库里面有多条记录,每条记录都是由小写字母组成,现在给出一个关键字,你能告诉我数据库里面有多少条与关键字相匹配的记录吗? 例如: 如果关键字是j*y*m*y?,那么jiyanmoyu ,jyanmoyu ,jymyu 都是相匹配的记录。 Input 第一行输入一个T (T ≤20),表示有T 组测试数据。对于每组测试数据,第一行是输入的关键字,接下是数据库里面的所有记录的条数n ,1≤n ≤10000,每条记录的长度不超过50个小写字母。 Output 对于每组测试数据,输出与关键字相匹配的总记录条数,占一行。 Sample Input Sample Output

acm程序设计大赛

acm程序设计大赛 一、参赛队的组成: 每只队伍三名参赛队员组成,设队长一名。 超过两名以上选手为女队员的参赛队可认为具有女队的资格。 在解出同等题目的情况下,女队优先,然后再计算时间(争夺第一名时除外)。 二、竞赛过程 竞赛中命题 6 题,比赛时间为5个小时。比赛编程语言为C或C++。 队员在接到题目后,编程进行解答,解答完每道题目,即可将程序通过网络提交,评委当场对提交的程序进行评判,并对提交的时间进行记录,经运行测试后由裁判判为正确或者错误,判决结果由系统自动反馈给参赛队伍。如果正确,就为该队挂上一个气球,不同颜色的气球代表不同的题目。为了增加比赛的紧张气氛,比赛结束前一个小时,停止公布所有的成绩。 参赛队员有权提交解释请求,针对题目描述中的不明确或错误的部分提问。如果裁判确认题目中确实存在不明确或错误的部分,将会通告所有参赛队伍进行声明或更正。 在竞赛中,参赛队员不得和同组成员以及竞赛组委会指定工作人员以外的人交谈;系统支持人员可以回答和系统相关的问题,例如解释系统错误信息。 参赛队员不能携带任何电子设备。允许携带纸质材料,包括源代码,参考书,字典等。 当参赛队伍出现妨碍比赛正常进行的行为时,诸如擅自移动赛场中的设备,未经授权修改比赛软硬件,干扰他人比赛等,都将会被竞赛组委会剥夺参赛资格。 三、竞赛评分 竞赛裁判主要负责当比赛选手对裁判系统的结果提出异议或题目需要人工判别时作出相应解释或判定。竞赛组委会主任在与竞赛裁判组协商后确定获胜队伍,有权根据由于不可预见的事件引起的问题,对结果进行调整,这个决定是最终的。 比赛最终结果由每支队伍解决的题目以及解决时间来决定。解题多者获胜,如果有队伍解题数量相同,则根据总用时加上惩罚时间进行排名。总用时和惩罚时间由每道解答正确的试题的用时加上惩罚时间组成。每道试题用时将从竞赛开始到试题解答被判定为正确为止,期间每一次错误的运行将被加罚20分钟时间,未正确解答的试题不计时。

acm程序设计大赛题目

The Mailboxes Manufacturers Problem Time Limit:1000MS Memory Limit:65536K Total Submit:299 Accepted:227 Description In the good old days when Swedish children were still allowed to blowup their fingers with fire-crackers, gangs of excited kids would plague certain smaller cities during Easter time, with only one thing in mind: To blow things up. Small boxes were easy to blow up, and thus mailboxes became a popular target. Now, a small mailbox manufacturer is interested in how many fire-crackers his new mailbox prototype can withstand without exploding and has hired you to help him. He will provide you with k(1 ≤ k≤ 10) identical mailbox prototypes each fitting up to m(1 ≤ m≤ 100) crackers. However, he is not sure of how many firecrackers he needs to provide you with in order for you to be able to solve his problem, so he asks you. You think for a while and then say, “Well,if I blow up a mailbox I can’t use it again, so if you would provide me with only k = 1 mailboxes, I would have to start testing with 1 cracker, then 2 crackers, and so on until it finally exploded. In the worst case, that is if it does not blow up ev en when filled with m crackers, I would need 1 + 2 + 3 + … + m = m ×(m+ 1) ? 2 crackers. If m = 100 that would mean more than 5000 fire-crackers!” “That’s too many,” he replies. “What if I give you more than k = 1 mailboxes? Can you find a strategy that requires less crackers?” Can you? And what is the minimum number of crackers that you should ask him to provide you with? You may assume the following: 1.If a mailbox can withstand x fire-crackers, it can also withstand x? 1 fire-crackers. 2.Upon an explosion, a mailbox is either totally destroyed (blown up) or unharmed, which means that it can be reused in another test explosion.

Acm试题及答案

Acm试题及答案 1001 Sum Problem (2) 1089 A+B for Input-Output Practice (I) (4) 1090 A+B for Input-Output Practice (II) (6) 1091 A+B for Input-Output Practice (III) (8) 1092 A+B for Input-Output Practice (IV) (9) 1093 A+B for Input-Output Practice (V) (11) 1094 A+B for Input-Output Practice (VI) (12) 1095 A+B for Input-Output Practice (VII) (13) 1096 A+B for Input-Output Practice (VIII) (14) 2000 ASCII码排序 (16) 2001计算两点间的距离 (17) 2002计算球体积 (19) 2003求绝对值 (20) 2004成绩转换 (21) 2005第几天 (22) 2006求奇数的乘积 (24) 2007平方和与立方和 (26) 2008数值统计 (27) 2009求数列的和 (28) 2010水仙花数 (29) 2011多项式求和 (31) 2012素数判定 (33) 2014青年歌手大奖赛_评委会打分 (34) 2015偶数求和 (36) 2016数据的交换输出 (38) 2017字符串统计 (40) 2019数列有序! (41) 2020绝对值排序 (43) 2021发工资咯:) (45) 2033人见人爱A+B (46) 2039三角形 (48) 2040亲和数 (49)

2017ACM比赛试题

2017年计算机ACM编程竞赛 主办:计算机科学与技术学院 时间:2017-11-22 18:00---20:00 地点:计算机学院奋进楼4楼5机房

竞赛规则 1、比赛时间为120分钟,从18:00开始,20:00结束。 2、比赛形式为上机编程,每个小组使用三台电脑,可任选语言,同一小组不同题目可使用不同语言; 3、比赛期间可以使用自己电脑,不可查阅书籍、但禁止查阅个人U盘,禁止使用手机、电脑进行上网查询,禁止使用现有代码,违者取消比赛资格;(正式ACM中是可以携带纸质材料的,但由于本次比赛,有大量题目参考书上例题,所以就不让携带了) 4、比赛期间,如遇到设备问题,可举手示意工作人员; 5、由于机房电脑系统有重启还原功能,比赛期间请勿轻易重启电脑; 6、【重要】比赛结束后,请确认将所要提交文件拷至工作人员U盘,否则成绩无效概不负责。 提交方式 1、创建文件夹,文件夹命名格式为小组号-小组队长-组员1-组员2 2、将每一题的源程序文件夹以题目编号命名,拷贝至上述创建的文件夹中 3、在本文档中每题相应位置附上源码及截图(windows截图键:Alt+Prt sc sysrq),拷贝至上述创建的文件夹中 4、比赛结束后将上述文件夹拷贝至工作人员U盘中,提交方算完成,提交 完成前请勿重启电脑。 注:本次比赛共14题,满分120分。没有完成题目,但有部分解题步骤者按完成度给分。每道题要有注释。

竞赛题目 1. 青年歌手大奖赛中,评委会给参赛选手打分。选手得分规则为去掉一个最高分和一个最低分,然后计算平均得分,请编程输出某选手的得分。输入数据有多组,每组占一行,每行的第一个数是n(2

2010程序设计大赛决赛题及参考答案

海南软件职业技术学院第四届计算机文化节 程序设计大赛决赛题 提醒:请各队在各自电脑D盘根目录下创建一个命名为“2010程序设计大赛-队名”的文件夹,将所有题目的答案都放到此目录底下。 做题过程中请注意保存。每做完一题就通过电子教室系统提交一次,电脑上没装电子教室软件的每题做完后举手示意工作人员用U盘提交。 各题源文件都分别保存在一个单独的文件夹中,文件夹命名为:题号_队名。 第一部分(简单题型): 1、(10分)马克思手稿中有一道趣味数学问题:有30个人,其中有男人、女人和小孩, 在一家饭馆吃饭花了50先令;每个男人花3先令,每个女人花2先令,每个小孩花1先令;问男人、女人和小孩各有几人?输出所有可能的组合。 样例输出: Men Women Children 1: 0 20 10 2: 1 18 11 3: 2 16 12 4: 3 14 13 5: 4 12 14 6: 5 10 15 7: 6 8 16 8: 7 6 17 9: 8 4 18 10: 9 2 19 11: 10 0 20 Java参考答案: void main() { int men,women,children; int count=0; printf(" %10s%10s%10s\n”,”men”,”women”,”children"); for(men=0;men<=16;men++) for(women=0;women<=25;women++) for(children=0;children<=30;children++) if(men+women+children==30&&men*3+women*2+children==50) { count++; printf(“%2d%10d%10d%10d\n”,count,men,women,children); } }

ACM程序设计竞赛例题

备战ACM资料 一:知识点 数据结构: 1,单,双链表及循环链表 2,树的表示与存储,二叉树(概念,遍历)二叉树的应用(二叉排序树,判定树,博弈树,解答树等) 3,文件操作(从文本文件中读入数据并输出到文本文件中) 4,图(基本概念,存储结构,图的运算) 数学知识 1,离散数学知识的应用(如排列组合、简单的图论,数理逻辑) 2,数论知识 3,线性代数 4,组合代数 5,计算几何 二算法 1,排序算法(冒抛法,插入排序,合并排序,快速排序,堆排序) 2,查找(顺序查找,二分发) 3,回溯算法 4,递归算法 5,分治算法 6,模拟法 7,贪心法 8,简单搜索算法(深度优先,广度优先),搜索中的剪枝,A*算法 9,动态规划的思想及基本算法 10,高精度运算 三、ACM竞赛的题型分析 竞赛的程序设计一般只有16种类型,它们分别是: Dynamic Programming (动态规划) Greedy (贪心算法) Complete Search (穷举搜索) Flood Fill (不知该如何翻译) Shortest Path (最短路径) Recursive Search Techniques (回溯搜索技术) Minimum Spanning Tree (最小生成树) Knapsack (背包问题) Computational Geometry (计算几何学) Network Flow (网络流) Eulerian Path (欧拉回路) Two-Dimensional Convex Hull (不知如何翻译) BigNums (大数问题)

Heuristic Search (启发式搜索) Approximate Search (近似搜索) Ad Hoc Problems (杂题) 四ACM竞赛参考书 《实用算法的分析与程序设计》(吴文虎,王建德著,电子工业出版社,竞赛类的黑宝书)《青少年国际和全国信息学(计算机)奥林匹克竞赛指导)――组合数学的算法 和程序设计》(吴文虎,王建德著,清华大学出版社,参加竞赛组合数学必学) 《计算机算法设计与分析》(王晓东编著,最好的数据结构教材) 《数据结构与算法》(傅清祥,王晓东编著,我所见过的最好的算法教材) 《信息学奥林匹克竞赛指导――1997-1998竞赛试题解析》(吴文虎,王建德著,清华大学出版社) 《计算机程序设计技巧》 D.E.Kruth著,算法书中最著名的《葵花宝典》,大师的作品,难度大) 《计算几何》周陪德著 《ACM国际大学生程序设计竞赛试题与解析(一)》(吴文虎著,清华大学出版社) 《数学建模竞赛培训教材》共三本叶其孝主编 《数学模型》第二版姜启源 《随机规划》 《模糊数学》 《数学建模入门》徐全智 《计算机算法设计与分析》国防科大 五常见的几个网上题库 常用网站: 1)信息学初学者之家:https://www.wendangku.net/doc/1113180970.html,/ (2)大榕树编程世界:https://www.wendangku.net/doc/1113180970.html,/~drs/program/default.asp (3)中国教育曙光网:https://www.wendangku.net/doc/1113180970.html,/aosai/ (4)福建信息学奥林匹克:https://www.wendangku.net/doc/1113180970.html,/fjas/index.htm (5)第20届全国青少年信息学奥林匹克竞赛:https://www.wendangku.net/doc/1113180970.html,/ (6)第15届国际青少年信息学奥林匹克竞赛:https://www.wendangku.net/doc/1113180970.html,/ (7)全美计算机奥林匹克竞赛:https://www.wendangku.net/doc/1113180970.html,/usacogate (8)美国信息学奥林匹克竞赛官方网站:https://www.wendangku.net/doc/1113180970.html,/ (9)俄罗斯Ural州立大学:http://acm.timus.ru/ (10)西班牙Valladolid大学:http://acm.uva.es/problemset (11)ACM-ICPC:https://www.wendangku.net/doc/1113180970.html,/icpc/ (12)北京大学:https://www.wendangku.net/doc/1113180970.html,/JudgeOnline/index.acm (13)浙江大学:https://www.wendangku.net/doc/1113180970.html,/ (14)IOI:http://olympiads.win.tue.nl/ioi/ (15)2003年江苏省信息学奥林匹克竞赛夏令营:https://www.wendangku.net/doc/1113180970.html, (16)https://www.wendangku.net/doc/1113180970.html, (17)https://www.wendangku.net/doc/1113180970.html, (18)https://www.wendangku.net/doc/1113180970.html, (19)https://www.wendangku.net/doc/1113180970.html,/downldmanag/index.asp (20)https://www.wendangku.net/doc/1113180970.html, colin_fox/colin_fox 五如何备战ACM/ICPC

河南省第四届ACM程序设计大赛原题

所有题目时间限制:1秒 【T1】 序号互换 Dr.Kong 设计了一个聪明的机器人卡多,卡多会对电子表格中的单元格坐标快速计算出来。单元格的行坐标是由数字编号的数字序号,而列坐标使用字符序号。观察字母序号,发现第1列到第26列的字母序号分别为A,B,……,Z,接着,第27列序号为AA,第28列为AB,以此类推。 若给Dr.Kong的机器人卡多一个数字序号(比如32),它能很快算出等价的字母序号(即AF),若给机器人一个字母序号(比如AA),它也能很快算出等价的数字序号(27),你能不能与卡多比试比试,看谁能算得更快更准。 【标准输入】 第一行:N 表示有多少组测试数据。 接下来N行,每行或者是一个正整数,或者是一个仅由大写字母组成的字符串。 【标准输出】 对于每一行测试数据,输出一行。如果输入为一个正整数序号,则输出等价的字母序号;如果输入为字符串,则输出等价的数字序号。 【约束条件】 输入保证,所有数字序号和字母序号对应的数字序号均<=2*10^9 【样例】 【T2】 节能 Dr.kong 设计的机器人卡多越来越聪明。最近市政府公司交给卡多一项任务,每天早晨5:00开始,它负责关掉ZK大道右侧上的所有路灯。 卡多每到早晨5:00准会在ZK大道上某盏灯的旁边,然后他开始关灯。每盏灯都有一定的功率,机器人卡多有自觉的节能意识,它希望在关灯期间,ZK大道右侧上所有的路灯的耗电总量数是最少的。 机器人卡多以1m/s的速度行走。假设关灯动作不需要花费额外的时间,因为当它通过某盏路灯时就

顺手将灯关掉。 请编写程序,计算在给定路灯设置,灯泡功率以及机器人卡多的起始位置的情况下,卡多关灯期间,Zk大道上所有灯耗费的最小能量。 【标准输入】 第一行N 表示ZK大道右侧路灯的数量(2<=N<=1000) 第二行V 表示机器人卡多开始关灯的路灯号。(1<=V<=N) 接下来的N行中,每行包含两个空格隔开的整数D和W,用来描述每盏灯的参数 D表示该路灯与ZK大道起点的距离(用米为单位来表示) W表示灯泡的功率,即每秒该灯泡所消耗的能量数。路灯是按顺序给定的。 (0<=D<=1000,0<=W<=1000) 【标准输出】 输出一个整数,即消耗总能量之和的最小值。注意结果小于200,000,000 【样例】 【T3】 表达式求值 Dr.Kong 设计的机器人卡多掌握了加减运算以后,最近又学会了一些简单的函数求值,比如,它知道函数min(20,23)的值是20,add(10,98)的值是108等等。经过训练,Dr.Kong 设计的机器人卡多甚至会计算一种嵌套的更复杂的表达式。 假设表达式可以简单定义为: 1.一个正的十进制数x是一个表达式。 2.如果x和y是表达式,则函数min(x.y)也是表达式,其值为x,y中最小的数。 3.如果x和y是表达式,则函数max(x,y)也是表达式,其值为x,y中最大数。 4.如果x和y是表达式,则函数add(x,y)也是表达式,其值为x,y之和。 例如,表达式max(add(1,2),7)的值为7. 请编写程序,对给定的一组表达式,帮助DrKong算出正确答案,以便校队卡多计算的正误。

历届程序设计acm试题

搜集的南开大学的ACM试题与你共享 [A]南开大学Onlinejudge 在线判题系统https://www.wendangku.net/doc/1113180970.html, A.Lucy的新难题 时间限制:2秒内存限制:32000KB 不知不觉,南开大学第三届“我为程序狂”又要拉开帷幕了。这天,Lucy也来到南开大学ACM协会,与大家共同欢庆NKPC的三周岁的日子。 谈笑间,ACM协会的主席拿了圆形的生日蛋糕。大伙开心地唱完了生日歌,一起吹灭了蜡烛。 要分蛋糕了,大家都很兴奋。本着公平的原则,每位到场的人员都要在蛋糕上切一刀。ACM协会的主席事先知道有n位朋友会参与这个欢庆宴会。为了方便大家切蛋糕,主席在订蛋糕的时候就嘱咐在蛋糕的边缘布置上2n朵小花。 每个人切蛋糕都会从蛋糕的边缘的一朵小花笔直地切到蛋糕的另一端的小花,来表达自己对NKPC的祝福。为了尊重其他同学,每个人在切蛋糕一定不会和蛋糕上已有的切痕相交,也不会从别人已切过的小花作为切蛋糕的起点或终点。同时,每位同学在切蛋糕的时候,都要保证后面所有的同学都能够按照上述的规则切蛋糕。这样,蛋糕上就留下n条切痕。 Lucy眨巴眨巴眼睛,问,要是不考虑切蛋糕的先后顺序和谁切的哪一刀,这蛋糕切完了共有多少种切法呢? 大家听了呵呵一笑,说,那就把这个问题留给NKPC3,作为《Lucy的新难题》吧。 相信聪明的你,一定能够帮Lucy解答她的难题的,对吗? 输入包括多组测试数据,你应当处理到输入结束为止。 每组输入数据中,都只有一行,仅包含一个正整数n,且0

2008年ACM大学生程序设计竞赛题

计算机科学系第二届大学生程序设计竞赛试题题目一 大数乘法 问题描述(Problem Description): 编程实现位数不超过300位的任意大的两个整数相乘。 输入(Input): 提示用户输入第一个大数乘数和第二个大数乘数。 输出(Output): 输出两个大数的乘积。 输入示例(Sample Input): 请输入第一个乘数:123456789123456 请输入第二个乘数:123456789123456 输出示例(Sample Output): 两数的乘积是:15230578580673373689799383936

四三二五六一题目二 排球队员站位问题 问题描述(Problem Description): 左图为排球场的平面图,其中一、二、三、 四、五、六为位置编号,二、三、四号位置为前排,一、六、五号位为后排。某队比赛时,一、四号位放主攻手,二、五号位放二 传手,三、六号位放副攻手。队员所穿球衣分别为1,2,3,4,5,6号,但每个队员的球衣都与他们的站位号不同。已知1号、6号队员不在后排,2号、3号队员不是二传手,3号、4号队员不在同一排,5号、6号队员不是副攻手。 编程求每个队员的站位情况。 输入(Input): 输出(Output): 输出每个队员球衣号码和所站的位置编号。 输入示例(Sample Input): 输出示例(Sample Output): 球衣号码:1 2 3 4 5 6 位置编号:一 二 三 四 五 六

题目三文件读写 问题描述(Problem Description): INI文件为一种广泛应用的储存程序配置的文件格式。要求不使用操作系统自带INI文件处理功能,用c++编写一个INI文件读取程序,并把结果输出到显示器及文件result.txt中。 说明: INI文件的结构: [区名字] # 区名注释 键名=键值 # 键值注释 一个区里可以有几个不同键名的键值,例如: 测试用INI文件test.ini: [section] #this is a section comment key=value #this is a key comment [section2] key2=value2 要求程序能读取section2区中键名为key2的值,以及section区中的键名为key的注释。 输入(Input): 在Windows命令窗口里输入程序名称来运行程序,注意程序所带参数。 输出(Output): 第一行输出section2区中键名为key2的值。 第二行输出section区中的键名为key的注释。 同时要把此结果输出到显示器和文件result.txt中。 输入示例(Sample Input): CppFileRW Test.ini 输出示例(Sample Output): section2区中键名为key2的值是:value2 section区中的键名为key的注释是:this is a key comment

历届百度之星程序设计大赛题目

2005年百度之星程序设计大赛试题初赛题目 第一题(共四题 100 分):连续正整数( 10 分) 题目描述:一个正整数有可能可以被表示为 n(n>=2) 个连续正整数之和,如: 15=1+2+3+4+5 15=4+5+6 15=7+8 请编写程序,根据输入的任何一个正整数,找出符合这种要求的所有连续正整数序列。 输入数据:一个正整数,以命令行参数的形式提供给程序。 输出数据:在标准输出上打印出符合题目描述的全部正整数序列,每行一个序列,每个序列都从该序列的最小正整数开始、以从小到大的顺序打印。如果结果有多个序列,按各序列的最小正整数的大小从小到大打印各序列。此外,序列不允许重复,序列内的整数用一个空格分隔。如果没有符合要求的序列,输出“NONE” 。 例如,对于 15 ,其输出结果是: 1 2 3 4 5 4 5 6 7 8

对于 16 ,其输出结果是: NONE 评分标准:程序输出结果是否正确。 百度之星程序设计大赛试题 -2 第二题(共四题 100 分):重叠区间大小( 20 分) 题目描述:请编写程序,找出下面“ 输入数据及格式” 中所描述的输入数据文件中最大重叠区间的大小。 对一个正整数 n ,如果 n 在数据文件中某行的两个正整数(假设为A 和 B )之间,即 A<=n<=B 或 A>=n>=B ,则 n 属于该行;如果 n 同时属于行 i 和 j ,则 i 和 j 有重叠区间;重叠区间的大小是同时属于行 i 和 j 的整数个数。 例如,行( 10 20 )和( 12 25 )的重叠区间为 [12 20] ,其大小为 9 ;行( 20 10 )和( 12 18 )的重叠区间为 [10 12] ,其大小为 3 ;行 (20 10) 和( 20 30 )的重叠区间大小为 1 。 输入数据:程序读入已被命名为 input.txt 的输入数据文本文件,该文件的行数在 1 到 1,000,000 之间,每行有用一个空格分隔的 2 个正整数,这 2 个正整数的大小次序随机,每个数都在 1 和 2^32-1 之间。(为便于调试,您可下载测试 input.txt 文件,实际运行时我们会使用不同内容的输入文件。)

桂林电子科技大学ACM程序设计校内竞赛试题

桂林电子科技大学ACM程序设计校内竞赛试题 ▲此套试题共8道,请根据自己实际情况尽最大努力去完成。 ▲每位参赛的同学需在考试用机的工作盘上创建一个名为Exam2004的临时文件夹用以保存所有的工作文件。上机编程调试出正确结果。按照试题顺序把每题的运行结果、源程序和算法说明(即解题思路说明)合并到一个Word 文档。该Word文档的文件名按如下格式命名:学号+姓名最后将该文件拷至制定的服务器上。 1、请看如下图4*4的一个网格。你能告诉我网格中隐含了多少正方形?也许你能手工数出 来,但是你能数100*100或者1000*1000的网格吗?请编写一个程序: 输入:输入一个整数N(0<=N<=100),代表网格的边长 输出:输出2维网格N*N中不同大小的正方形的数目S. 如以上4*4网格共有正方形30 2、对于一个8位二进制码,它的镜像就是将它的第n位于倒数第n位交换,使它的每一位 都这样交换。例如,代表十进制数46的二进制数是00101110。它的镜像是二进制码01110100,即十进制数116。编写一个程序,输入一个整数N(如46),输出其镜像M(如116)。 3、给你9个整数,这9个整数分别是x的8次方至0次方的系数,请你按照多项式的一般 形式合理地构造(去除不必要的)。例如9个系数分别为0,0,0,1,22,-333,0,1,-1,你要构造并输出一行多项式: x^5+22x^4-333x^3+x-1。要求:可以输入多行系数,再显示结果。 如输入: 0 0 0 1 22 -333 0 1 -1 0 0 0 0 0 0 6 88 0 E(输入结束标志) 输出: x^5+22x^4-333x^3+x-1 6x^2+88x 4、美国人的家族 农夫John对他的奶牛继承关系非常认真。但是他不是一个很好的记录员,他以一种二叉树的方法来记录他奶牛的继承关系。他用字符串来记录一棵树的前序、中序遍历,而不是用图形方式来表示这棵树。你的任务是对于给出的奶牛继承关系的前序树和中序树表示,找出它的后序树表示。每个奶牛的名字用一个字母来代表。 输入规范 第一行输入中序序列 第二行输入前序序列 输出规范 显示后序序列 实例输入 In order: AEDFCHG // 中序序列输入

acm编程比赛题

比赛试题 主办方:迅翔计算机协会

【问题描述】 这是一个古老而又经典的问题。用给定的几种钱币凑成某个钱数,一般而言有多种方式。例如:给定了6种钱币面值为2、5、10、20、50、100,用来凑15元,可以用5个2元、1个5元,或者3个5元,或者1个5元、1个10元,等等。显然,最少需要2个钱币才能凑成15元。 你的任务就是,给定若干个互不相同的钱币面值,编程计算,最少需要多少个钱币才能凑成某个给出的钱数。 【要求】 【数据输入】输入可以有多个测试用例。每个测试用例的第一行是待凑的钱数值M(1 <= M <= 2000,整数),接着的一行中,第一个整数K(1 <= K <= 10)表示币种个数,随后是K 个互不相同的钱币面值Ki(1 <= Ki <= 1000)。输入M=0时结束。 【数据输出】每个测试用例输出一行,即凑成钱数值M最少需要的钱币个数。如果凑钱失败,输出“Impossible”。你可以假设,每种待凑钱币的数量是无限多的。 【样例输入】 15 6 2 5 10 20 50 100 1 1 2 【样例输出】 2 Impossible

【问题描述】 Felicia 的生日是11月1日(和Kitty是同一天生的哦)。于是Feli请来Kitty一起过生日。Kitty带来了最新款的“Kitty猫”玩具准备送给Feli,不过她说,这份礼物可不是白送的。Feli要帮她一个忙,才能够得到心仪已久的玩具。Kitty说,“Kitty猫”玩具已经卖出了n!个,n<=10^100 *_*,Kitty想知道确切的数字,而不是无聊的“一个数加个感叹号”。Feli 听了大吃一惊。要知道,算出n!是一个无比艰巨的任务。Feli告诉Kitty,就算Feli算出n!,Kitty也看不下去,因为当n=20 时,计算机的长整型已经存不下了(Kitty只能接受1-9之间的数字)。于是Kitty说,你只要告诉我n!最后一位非0的数就可以了。Feli想了想,立刻动手写了个程序算出了正确的答案。现在,请你也试试看!注意哦,AC的男生将会得到一个“Hello Kitty”计算器(可编程,CPU 1THz,Mem 1TMB),AC的女生将会得到一个仿真“Hello Kitty”宠物(善解人意,无须喂养,智商1101,附带写情书功能)。 【要求】 【数据输入】每行一个n,直到输入数据结束 【数据输出】对应输入的n,每行输出一个答案 【样例输入】 1101 【样例输出】 8

ACM程序设计大赛(校级)

Problem A ISBN号码 Description 每一本正式出版的图书都有一个ISBN号码之对应,ISBN码包括9位数字、1位识别码和3位分隔符,其规定格式如“x-xxx-xxxxx-x”,其中符号“-”是分隔符(键盘上的减号),最后一位是识别码,例如0-670-82162-4就是一个标准的ISBN码。ISBN码的首位数字表示书籍的出版语言,例如0代表英语;第一个分隔符“-”之后的三位数字代表出版社,例如670代表维京出版社;第二个分隔之后的五位数字代表该书在该出版社的编号;最后一位为识别码。 识别码计算方法如下: 首位数字乘以1加上次位数字乘以2……以此类推,所得的结果mod 11,所得的余数即为识别码,如果余数为10,则识别码为大写字母X。例如ISBN号码0-670-82162-4中的识别码4是这样得到的:对067082162这9个数字,从左至右,分别乘以1,2.,……,9,再求和,即0×1+6×2+……+2×9=158,然后取158 mod 11 的结果4作为识别码。 你的任务是编写程序判断输入的ISBN号码中识别码是否正确,如果正确,则仅输出“Right”;如果错误,则输出你认为是正确的ISBN号码。 Input 输入只有一行,是一个字符序列,表示一本书的ISBN号码(保证输入符合ISBN号码的格式要求)。 Output 输出共一行,假如输入的ISBN号码的识别码正确,那么输出“Right”,否则,按照规定格式,输出正确的ISBN号码(包括分隔符“-”)。 Sample1 Input 0-670-82162-4 Sample2 Input 0-670-82162-0 Sample1 Output Right Sample2 Output 0-670-82162-4

四川理工学院2012年ACM程序设计赛试题

2012年四川理工学院“达内杯”大学生程序设计竞赛试题 Problem 1:Sorting There are 16 random sorting numbers from 0 to 15, and they could be converted to different binary numbers, which have 4 digits. Please code algorithm to sort them by the order that the first there digits of the former number is same to the last there digits of the following. The first number of the sorted is always the first given number. Sample Input: 1 3 5 7 9 11 13 15 0 2 4 6 8 10 12 14 Sample Output: 1 2 4 9 3 7 15 14 13 10 5 11 6 12 8 0 Problem 2:Solution of Equation In the interval [0,1], please programming to give the real root, of which error is less than 10-3, of equation ax3+bx2+cx+d=0, where a, b ,c and d are real number. And print the real root or the character “no solution”. Sample Input: 1:a =1 b =-1 c =-2 d =1 2:a =1 b =1 c =1 d =1 Sample Output: 1:x =0.444335937 2:no solution

第三届ACM程序设计大赛试题new

计算机工程学院 第三届ACM程序设计大赛试题 Problem A Bridge Description n people wish to cross a bridge at night. A group of at most two people may cross at any time, and each group must have a flashlight. Only one flashlight is available among the n people, so some sort of shuttle arrangement must be arranged in order to return the flashlight so that more people may cross. Each person has a different crossing speed; the speed of a group is determined by the speed of the slower member. Your job is to determine a strategy that gets all n people across the bridge in the minimum time. Input The first line of input contains n, followed by n lines giving the crossing times for each of the people. There are not more than 1000 people and nobody takes more than 100 seconds to cross the bridge. Output The first line of output must contain the total number of seconds required for all n people to cross the bridge. The following lines give a strategy for achieving this time. Each line contains either one or two integers, indicating which person or people form the next group to cross. (Each person is indicated by the crossing time specified in the input. Although many people may have the same crossing time the ambiguity is of no consequence.) Note that the crossings alternate directions, as it is necessary to return the flashlight so that more may cross. If more than one strategy yields the minimal time, any one will do. Sample Input(Input file: pa.txt) 4 1 2 5 10 Sample Output 17 1 2 1 5 10 2 1 2

相关文档
相关文档 最新文档