| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 5135 人关注过本帖
标题:ACM题集(即时更新)
只看楼主 加入收藏
PcrazyC
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:5652
专家分:0
注 册:2006-10-20
收藏
得分:0 

来了没,王永亮

[此贴子已经被作者于2007-4-15 13:38:23编辑过]


雁无留踪之意,水无取影之心
2007-03-31 22:11
crackerwang
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:833
专家分:0
注 册:2007-2-14
收藏
得分:0 

近来了


2007-04-15 13:38
spider1987
Rank: 1
等 级:新手上路
帖 子:172
专家分:0
注 册:2007-2-18
收藏
得分:0 
英文不好。。。看不懂- -
2007-04-15 13:46
PcrazyC
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:5652
专家分:0
注 册:2006-10-20
收藏
得分:0 

Contest Problem E : The gamblers

Time Limit: 1000 MS Memory Limit: 65536 K
Total Submit: 67 Accepted: 16

Description

There are N gamblers,one day,they want to find the person who is the best.Each time,three of them have a match,and two of them lose the game.Sometimes two of them have a match may needed.There are a lot of gamblers,so they want the match as fewer as possible.Give the number of N,can you tell the number of matches.

Input

The input contains several test cases. Each case is specified by one positive integer n (0 < n <= 1000000000), indicating the number of players.

Output

For each test case, output a single line with the least number of matches.

Sample Input

3
4
5
Sample Output

1
2
2


第二题:

Contest Problem D : Mine again

Time Limit: 1000 MS Memory Limit: 65536 K
Total Submit: 17 Accepted: 6

Description

Typhoon likes playing a game named "Mine Sweeper". Have you ever played it ?
The game Minesweeper is played on an n by n grid. In this grid are hidden m mines, each at a distinct grid location. The player repeatedly touches grid positions. If a position with a mine is touched, the mine explodes and the player loses. If a position not containing a mine is touched, an integer between 0 and 8 appears denoting the number of adjacent or diagonally adjacent grid positions that contain a mine.
//这个地方是一个扫雷的图,复制不上来,知道是扫雷就可以了

Now , giving you the position of the mines , your task is to print the number of all grids.


Input

The first line of input contains a single positive integer n <= 100. The next n lines represent the positions of the mines. Each line represents the contents of a row using n characters: "*" indicates a mined position while "." indicates a position with no mine .

Input contains multiple test cases. Process to the end of file.
Output

Your output should represent the board.Grids that do not contain a mine should contain an integer between 0 and 8 , else print "*".

Separate output for subsequent test cases with a single blank line.

Sample Input

8
...**..*
......*.
***.*...
*.*.....
***.....
.....*..
...**.*.
.....*..
Sample Output

001**22*
233433*2
***3*211
*8*41100
***21110
23333*21
001**4*1
00123*21

第三题:

Contest Problem C : Joseph's problem

Time Limit: 5000 MS Memory Limit: 65536 K
Total Submit: 20 Accepted: 14

Description


The Joseph's problem is well known for us.There are N person stand in a circle,and the Mth person has to leave.Assume that we always start from the person 1,and give the number N and M,can you tell me who is the person that the last to leave.
Input

Input contains multiple test cases. For each test case,there is one line containing two integers N and M (1000>=N>M>1), where N represents the number of person and M means that every Mth is going to leave.

Output

For each test case, output a single line with the number of the person last to leave.

Sample Input

5 3
Sample Output

4

第四题:

Contest Problem B : How fast can I drive

Time Limit: 1000 MS Memory Limit: 65536 K
Total Submit: 24 Accepted: 4

Description

There are N city and M roads connect them,and each road is bidirectional with a number stand
the fastest speed you can drive.I want to go from city 0 to city N-1(1<=N<1000),if the car have to drive in a changeless speed,can you tell me the fastest speed I can drive.

Input

Input contains multiple test cases. For each test case,there is one line containing two integers N and M , where N represents the number of city and M represents the number of road.Then M lines follows,each line contain three integers A,B,Speed.It means the fastest speed between A and B is Speed.

Output

For each test case, output a single line with fastest speed .If you can't find a path from 0 to N-1,just output -1 in s single line.

Sample Input

3 3
1 2 5
2 3 5
1 3 4
4 4
1 2 8
2 3 5
2 4 7
3 4 7

Sample Output

5
7

第五题:

Contest Problem F : The problem with Tom

Time Limit: 1000 MS Memory Limit: 65536 K
Total Submit: 7 Accepted: 3

Description

One day,Tom's teacher give him a problem,give a number N(1<=N<=1000),it can be writen as a sum of some of positive integer.As N=s1+s2+s3+….But si must be the power of 2.Then Tom has to tell how many way are there can from N.If two sequences have the same number but different order,they consider as one.Tom is poor in math,so as his best friend,slove this problem for him.
Input

Input consists of multiple test cases. Eath case contain a number N which described as before.

Output

For eath number,output a number stand the number of different kinds of string.

Sample Input

2
5
Sample Output

2
4


第六题:

Contest Problem G : The problem with TomⅡ

Time Limit: 1000 MS Memory Limit: 65536 K
Total Submit: 6 Accepted: 2

Description

Another day,Tom's teacher give him one more problem,use three letter 't','h','e' to form a string with length of N.But 't' will not appear in adjacent position.Then the problem is to find the number of different kind of the string.Tom is poor in math,so as his best friend,slove this problem for him.
Input

Input consists of multiple test cases. Eath case contain a number N (1<=N<1000) stands the length of the string.
Output

For eath number,output a number stand the number of different kinds of string.

Sample Input

1
2
Sample Output

3
8
Hint

The number of output maybe so large that can exceed the range of long or double.

第七题:

Contest Problem H : Who is the best

Time Limit: 1000 MS Memory Limit: 65536 K
Total Submit: 18 Accepted: 2

Description

In every examnation,we all get a score given by our teacher,and we can say that the one who gets the highest score is the best.However,we can redefine another rule:there are n students, given the score array s[n]: s1,s2,s3...sn ,based on the ith num,we redefine the ith student's score by T[i]=|S1-Si|+|S2-Si|+…|Sn-Si|,so we can get another array T[n],you just need to output the highest result T[i].

Input

There are multiple test cases.In every case , there are a line with a integer n(1<=n<=100000000) representing the number of the students, the second line contains n integers representing the scores of the students.

Output

Output a line with the highest result.
Sample Input

3
1 2 3
Sample Output

3

第八题:

Contest Problem I : Help July

Time Limit: 1000 MS Memory Limit: 65536 K
Total Submit: 11 Accepted: 7

Description

July 特别喜欢吃苹果。一天他的朋友 fwish 送给他N个苹果,每个苹果的颜色都各有特色。
他马上想把这些苹果马上吃光,但是......
fwish 知道July 很聪明,所以这次她想难为一下July。她要July把这N个苹果通过她的规则归并成一堆,
要是能做到的话,就让他马上吃苹果。
July只好答应了。
fwish的规则如下:

1.所有苹果都已经标好号,按顺序排好,每个苹果都有个值。
2.每次只能合并相邻的两堆。
3.开始的时候每堆只有一个苹果。
4.合并得到新堆的值为合并之前两堆的值之和,该次合并的代价为新堆的值。
5.最后将所有苹果合并成一堆.
6.合并的总代价为每次合并的代价累加之和。

fwish 要求July 计算出总代价的最小值。 July想了半天也没想到一种方法来解决这个问题。
July 知道你是一个数学和计算编程机高手,于是他请求你帮助他,
因为 fwish 的规则没有说不能请别人帮忙。

Input

有多组数据,以 N = 0 结束。
每个CASE:
第一行包含一个数N(1<=N<=100),代表 苹果的个数 。
第二行有N个数,表示这N个苹果的值。
Output

每个CASE包含一行,输出N个苹果合并成一堆的最小得分。
Sample Input

4
13 7 8 16
Sample Output

87

第九题:

Contest Problem J : Money and Happy to BJF

Time Limit: 1000 MS Memory Limit: 65536 K
Total Submit: 14 Accepted: 2

Description

BJF 是一个建筑工地的工头,他现在遇到了一个问题需要他的工作秘书 你设计一个程序来解决他的问题。
问题是这样的:
现在 BJF 有一个工程学要做N个月,第i个月需要至少a[i]个工人。由于每个需要工人数不一样,所以他可以做合理安排(每个月辞退或雇佣一些工人,以便保证工程的正常进行),每个工人 每月工资为S,辞退一个工人要额外支付 F, 雇佣一个工人要额外支付 H;BJF希望完成工程花费 越少越好,并且在不影响花费的前提下最后剩下的工人越多越好(这样BJF最Happy )。
Input

包含多个CASE, 以 N = 0 结束。
每个CASE包含三行:
第一行一个N ( 1<= N <= 50 )代表 工程要N个月才能完成。第二行有三个数 H, S, F( 0 <= H, S, F <= 15; 第三行包含N个数 { a[1], a[2], ...,a[i], ..., a[n]; 0 <= a[i] <= 510 }
a[i]( 1 <= i <= N )代表第i个月至少要a[i]个工人。
Output

每个CASE 包含一行:最小花费和在最小花费前提下,剩下的最大工人数。以一个空格分开
Sample Input

2
1 1 1
1 1
Sample Output

3 1

第十题:

Contest Problem A : A math problem

Time Limit: 1000 MS Memory Limit: 65536 K
Total Submit: 46 Accepted: 1

Description

There are two sequeues of integer,can you tell me whether you can get the second from the first one through the operation as follows:
For S[i-1],S[i],S[i+1],you can get S[i-1]+s[i],s[i]-2*s[i],s[i+1]+s[i].
For example:
3 5 6 7
8 6 -11 18

Then ,from 3 5 6 7, we can get 8 -5 11 7 through the first operation on( 3 5 6 ),then we can get 8 6 -11 18 through the second one on ( -5 11 7 ),so the answer is YES;
Input

Input contains multiple test cases.For each test case,there is one line containing one integers N(3<=N<1000),
where N represents the number of integers of the sequence.Then two lines follows,each line with N integers,respectively.

Output

For each test case,if you can get the second sequence from the first one,output YES, or ouput NO.

Sample Input

4
3 5 6 7
8 6 -11 18
Sample Output

YES


雁无留踪之意,水无取影之心
2007-04-15 17:25
crackerwang
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:833
专家分:0
注 册:2007-2-14
收藏
得分:0 

终于搞出第7个
#include<stdio.h>

void main()
{
__int64 i,sum1,sum2,max,min,n,k;
while(scanf("%I64d",&n)!=EOF)
{
scanf("%I64d",&k);
sum1=sum2=k;
max=min=k;
for(i=1;i<n;i++)
{
scanf("%l64d",&k);
sum1+=k;
if(k>max)
max=k;
if(k<min)
min=k;
}
max=n*max-sum1;
min=sum1-min*n;
printf("%I64d\n",min>max?min:max);
}
}

[此贴子已经被作者于2007-4-16 13:25:37编辑过]


2007-04-16 11:59
w5560
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2007-4-16
收藏
得分:0 
给我传点中文的题目呗,刚刚学,做英文的有点不顺手,先试试中文的
2007-04-16 16:49
crackerwang
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:833
专家分:0
注 册:2007-2-14
收藏
得分:0 

第一个到第三个简单
哈哈
#include<stdio.h>
void main()
{
long n,i,k;
while(scanf("%ld",&n)!=EOF)
{
printf("%ld\n",n/2);
}
}

#include<stdio.h>
void main()
{
char s[110][110];
int n,j,i;
while(scanf("%d",&n)!=EOF)
{
for(i=0;i<n;i++)
scanf("%s",s[i]);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(s[i][j]!='*')
{
s[i][j]='0';
if(i-1>=0&&j-1>=0&&s[i-1][j-1]=='*')
s[i][j]++;
if(i-1>=0&&s[i-1][j]=='*')
s[i][j]++;
if(i-1>=0&&j+1<n&&s[i-1][j+1]=='*')
s[i][j]++;
if(j-1>=0&&s[i][j-1]=='*')
s[i][j]++;
if(j+1<n&&s[i][j+1]=='*')
s[i][j]++;
if(i+1<n&&j-1>=0&&s[i+1][j-1]=='*')
s[i][j]++;
if(i+1<n&&s[i+1][j]=='*')
s[i][j]++;
if(i+1<n&&j+1<n&&s[i+1][j+1]=='*')
s[i][j]++;
}
}
}
for(i=0;i<n;i++)
{
printf("%s\n",s[i]);
}
printf("\n");
}
}

#include<stdio.h>
#include<stdlib.h>
struct node
{
int i;
struct node *a;
struct node *b;
};
void main()
{
struct node *head,*q,*p;
int n,m,i;
while(scanf("%d %d",&n,&m)!=EOF)
{
i=1;
p=(struct node *)malloc(sizeof(struct node));
p->i=1;
head=p;
while(--n)
{
q=(struct node *)malloc(sizeof(struct node));
q->i=++i;
p->a=q;
q->b=p;
p=p->a;
}
p->a=head;
head->b=p;
i=0;
while(p->a!=p)
{
i++;
p=p->a;
if(i==m)
{
i=0;
q=p->b;
q->a=p->a;
free(p);
p=q->a;
p->b=q;
p=q;
}

}
printf("%d\n",p->i);
free(p);
}
}


2007-04-16 16:52
PcrazyC
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:5652
专家分:0
注 册:2006-10-20
收藏
得分:0 
以下是引用w5560在2007-4-16 16:49:05的发言:
给我传点中文的题目呗,刚刚学,做英文的有点不顺手,先试试中文的

好吧,我过几天去机房搞几个中文的来


雁无留踪之意,水无取影之心
2007-04-16 21:21
iwfy
Rank: 1
等 级:新手上路
威 望:2
帖 子:888
专家分:0
注 册:2007-2-23
收藏
得分:0 
第5题,我的这个分析错误,16以后就错了,所以删掉

[此贴子已经被作者于2007-4-18 16:53:16编辑过]


英语不好还想学编程??逆天之路,不由分说!! 数学太差还想学编程??离经叛道,义无返顾!!
2007-04-17 06:26
crackerwang
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:833
专家分:0
注 册:2007-2-14
收藏
得分:0 
应该有比这个还要简单一点的方法

2007-04-17 09:25
快速回复:ACM题集(即时更新)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.074298 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved