最新的ACM题目!!!!向有志者挑战!!!英语加C语言!!!标清题号,交流一下!!!

dapao74110 2011-06-28 09:50:28
题目一::

The Fibonacci Numbers {0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 ,...} are defined by the recurrence:
F0 = 0
F1 = 1
Fi = Fi-1 + Fi-2 for all i >= 2
Write a program to calculate the Fibonacci Numbers.



Input
The first line of the input file contains a single integer T, the number of test cases. The following T lines, each contains an integer n ( 0 <= n <= 45 ), and you are expected to calculate Fn.
Output
Output Fn on a separate line.

题目二:

A checksum is an algorithm that scans a packet of data and returns a single number. The idea is that if the packet is changed, the checksum will also change, so checksums are often used for detecting transmission errors, validating document contents, and in many other situations where it is necessary to detect undesirable changes in data.

For this problem, you will implement a checksum algorithm called Quicksum. A Quicksum packet allows only uppercase letters and spaces. It always begins and ends with an uppercase letter. Otherwise, spaces and letters can occur in any combination, including consecutive spaces.

A Quicksum is the sum of the products of each character's position in the packet times the character's value. A space has a value of zero, while letters have a value equal to their position in the alphabet. So, A=1, B=2, etc., through Z=26. Here are example Quicksum calculations for the packets "ACM" and "MID CENTRAL":

ACM: 1*1 + 2*3 + 3*13 = 46
MID CENTRAL: 1*13 + 2*9 + 3*4 + 4*0 + 5*3 + 6*5 + 7*14 + 8*20 + 9*18 + 10*1 + 11*12 = 650



Input
The input consists of one or more packets followed by a line containing only # that signals the end of the input. Each packet is on a line by itself, does not begin or end with a space, and contains from 1 to 255 characters.
Output
For each packet, output its Quicksum on a separate line in the output.




题目三::
Description
Your task is about the scoring in the first phase of the die-game Yahtzee, where five dice are used. The score is determined by the values on the upward die faces after a roll. The player gets to choose a value, and all dice that show the chosen value are considered active. The score is simply the sum of values on active dice.
Say, for instance, that a player ends up with the die faces showing 2, 2, 3, 5 and 4. Choosing the value two makes the dice showing 2 active and yields a score of 2 + 2 = 4, while choosing 5 makes the one die showing 5 active, yielding a score of 5.


Input
Each line is a case.
Toss will contain exactly 5 elements.
Each element of toss will be between 1 and 6, inclusive.


Output
return the maximum possible score with these values.


Sample Input
2 2 3 5 4
6 4 1 1 3
5 3 5 3 3

Sample Output
5
6
10
...全文
250 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
TPOF314 2011-08-05
  • 打赏
  • 举报
回复
我晕,看了第一题就没兴趣了。
题目太水了~~~~
636f6c696e 2011-08-05
  • 打赏
  • 举报
回复
除了题目是英语外,别无难度...
秋雨潇湘 2011-08-05
  • 打赏
  • 举报
回复
其实第一题可以通过矩阵加速一下,不过那个好象没有必要!
FrankHB1989 2011-08-05
  • 打赏
  • 举报
回复
时间都不给?
看在都是水题的份上就算了……

c271525290 2011-08-05
  • 打赏
  • 举报
回复
不会,帮顶
leighjian 2011-08-04
  • 打赏
  • 举报
回复
顶上,学习
Leaveye 2011-08-04
  • 打赏
  • 举报
回复
1. F45 = 1134903170 < 2147483647 = 2^31 - 1 so int enough.
int fib( int i ) { static int rs[46] = {0,1}; if ( !i || rs[i] ) return rs[i]; return rs[i] = fib( i-1 ) + fib ( i-2 ); }

2. QuickSum( const char *s ) { if ( !s ) return 0; else { register int r = 0, i; for ( i=1; *s; i++, s++ ) r += i**s; return r; }

3. much more easy.
for ( each line ... ) {
int r[6] = {}, i, c;
for ( i=0; i<5 && scanf( "%d", &c ); i++ ) r[c-1] += c;
if ( i<5 ) break;
for ( c=r[0], i=1; i<6; i++ ) if ( r[i] > c ) c = r[i];
printf( "%d\n", c );
}
changshuaia 2011-08-04
  • 打赏
  • 举报
回复
等解!
AndyZhang 2011-08-04
  • 打赏
  • 举报
回复
都是很简单的题目,感觉如果高ACM练习这些题目,入门可以,不过不太适合,有点简单,还是来boj吧
AndyZhang 2011-08-04
  • 打赏
  • 举报
回复
第一题我把所有的都输出了,你看着改改吧!!!

第3题:


#include <stdio.h>
int main()
{
int num[7],i;

int a,b,c,d,e;
while(scanf("%d%d%d%d%d", &a, &b, &c, &d, &e) != EOF)
{
for (i = 1; i < 7; i ++)
{
num[i] = 0;
}
num[a]++;
num[b]++;
num[c]++;
num[d]++;
num[e]++;
int max = 0;
for (i = 1; i < 7; i ++)
{
if (max < i * num[i])
{
max = i * num[i];
}
}
printf("%d\n", max);
}

}



AndyZhang 2011-08-04
  • 打赏
  • 举报
回复
问题2:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char str[256];

while (1)
{
gets(str);
if (str[0] == '#')
{
break;
}
int sum,len;
sum = 0;
len = strlen(str);
int i;
for (i = 0; i < len ; i ++)
{
if (str[i] >= 'A' && str[i] <= 'Z')
{
sum += (str[i] - 'A' + 1)*(i + 1);
}
}
printf("%d\n", sum);
}


//getchar();
}
liutengfeigo 2011-08-04
  • 打赏
  • 举报
回复
还最新?你原创的啊?
AndyZhang 2011-08-04
  • 打赏
  • 举报
回复
#include <stdio.h>
int main()
{
__int64 a[46];

a[0] = 0;
a[1] = 1;
int i = 0;
for (i = 2; i < 46;i ++)
{
a[i] = a[i - 1] + a[i - 2];
}

for ( i = 0; i < 46; i ++)
{
printf("%I64d\n",a[i]);
}

getchar();
}

0
1
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181
6765
10946
17711
28657
46368
75025
121393
196418
317811
514229
832040
1346269
2178309
3524578
5702887
9227465
14930352
24157817
39088169
63245986
102334155
165580141
267914296
433494437
701408733
1134903170
richardgates 2011-08-04
  • 打赏
  • 举报
回复
第一题 斐波纳契数列
第二题 根据QuickSum方法计算校验和
第三题 好像是个游戏骰子计算
luciferisnotsatan 2011-08-04
  • 打赏
  • 举报
回复
帮顶!
至善者善之敌 2011-08-04
  • 打赏
  • 举报
回复
帮顶!
pathuang68 2011-08-04
  • 打赏
  • 举报
回复
都不算难的干活。
kcill 2011-08-04
  • 打赏
  • 举报
回复
额。。竟然没人回复。。。。第二个问题我也不会,同样坐等答案~~

70,037

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧