当前位置:文档之家› 杭电ACM水题题目及代码

杭电ACM水题题目及代码

杭电ACM水题题目及代码
杭电ACM水题题目及代码

1001

#include

int main()

{

int i,a,j;double sum;

while(scanf("%d",&a)!=EOF)

{

sum=0;

for(j=1;j<=a;j++)

{

sum+=j;

}

printf("%.0lf\n\n",sum);

}

return 0;

}

1002 A + B Problem II

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 69615 Accepted Submission(s): 12678

Problem Description

I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.

Input

The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line consists of two positive integers, A and B. Notice that the integers are very large, that means you should not process them by using 32-bit integer. You may assume the length of each integer will not exceed 1000.

Output

For each test case, you should output two lines. The first line is "Case #:", # means the number of the test case. The second line is the an equation "A + B = Sum", Sum means the result of A + B. Note there are some spaces int the equation. Output a blank line between two test cases.

Sample Input

2

1 2

112233445566778899 998877665544332211

Sample Output

Case 1:

1 +

2 = 3

Case 2:

112233445566778899 + 998877665544332211 = 1111111111111111110 Author

Ignatius.L

#include

#include

int main(){

char str1[1001], str2[1001];

int t, i, len_str1, len_str2, len_max, num = 1, k;

scanf("%d", &t);

getchar();

while(t--){

int a[1001] = {0}, b[1001] = {0}, c[1001] = {0};

scanf("%s", str1);

len_str1 = strlen(str1);

for(i = 0; i <= len_str1 - 1; ++i)

a[i] = str1[len_str1 - 1 - i] - '0';

scanf("%s",str2);

len_str2 = strlen(str2);

for(i = 0; i <= len_str2 - 1; ++i)

b[i] = str2[len_str2 - 1 - i] - '0';

if(len_str1 > len_str2)

len_max = len_str1;

else

len_max = len_str2;

k = 0;

for(i = 0; i <= len_max - 1; ++i){

c[i] = (a[i] + b[i] + k) % 10;

k = (a[i] + b[i] + k) / 10;

}

if(k != 0)

c[len_max] = 1;

printf("Case %d:\n", num);

num++;

printf("%s + %s = ", str1, str2);

if(c[len_max] == 1)

printf("1");

for(i = len_max - 1; i >= 0; --i){

printf("%d", c[i]);

}

printf("\n");

if(t >= 1)

printf("\n");

}

return 0;

}

成绩转换

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 25250 Accepted Submission(s): 10776

Problem Description

输入一个百分制的成绩t,将其转换成对应的等级,具体转换规则如下:

90~100为A;

80~89为B;

70~79为C;

60~69为D;

0~59为E;

Input

输入数据有多组,每组占一行,由一个整数组成。

Output

对于每组输入数据,输出一行。如果输入数据不在0~100范围内,请输出一行:“Score is error!”。

Sample Input

56

67

100

123

Sample Output

E

D

A

Score is error!

Author

lcy

Source

C语言程序设计练习(一)

Recommend

JGShining

#include

int main(){

int n, k;

while(scanf("%d", &n) != EOF){

if(n < 0 || n >100)

printf("Score is error!\n");

else{

k = n / 10;

switch(k){

case 10: printf("A\n"); break;

case 9: printf("A\n"); break;

case 8: printf("B\n"); break;

case 7: printf("C\n"); break;

case 6: printf("D\n"); break;

default: printf("E\n"); break;

}

}

}

return 0;

}

2007平方和与立方和

Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)

Total Submission(s) : 65 Accepted Submission(s) : 9

Font: Times New Roman | Verdana | Georgia

Font Size: ←→

Problem Description

给定一段连续的整数,求出他们中所有偶数的平方和以及所有奇数的立方和。

Input

输入数据包含多组测试实例,每组测试实例包含一行,由两个整数m和n组成。Output

对于每组输入数据,输出一行,应包括两个整数x和y,分别表示该段连续的整数中所有偶数的平方和以及所有奇数的立方和。

你可以认为32位整数足以保存结果。

Sample Input

1 3

2 5

Sample Output

4 28

20 152

Author

lcy

Source

C语言程序设计练习(一)

Statistic |

#include

int main()

{

int x , y, temp, sum1, sum2;

while(scanf("%d %d", &x, &y) != EOF)

{

sum1 = 0;

sum2 = 0;

if(x > y)

{

temp = x;

x = y;

y = temp;

}

for(; x <= y; x++)

{

if( x % 2 == 0)

{

sum1 += x * x;

}

else

sum2 += x * x * x;

}

printf("%d %d\n", sum1, sum2);

}

return 0;

}

2010水仙花数

Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 144 Accepted Submission(s) : 27

Font: Times New Roman | Verdana | Georgia

Font Size: ←→

Problem Description

春天是鲜花的季节,水仙花就是其中最迷人的代表,数学上有个水仙花数,他是这样定义的:“水仙花数”是指一个三位数,它的各位数字的立方和等于其本身,比如:

153=1^3+5^3+3^3。

现在要求输出所有在m和n范围内的水仙花数。

Input

输入数据有多组,每组占一行,包括两个整数m和n(100<=m<=n<=999)。Output

对于每个测试实例,要求输出所有在给定范围内的水仙花数,就是说,输出的水仙花数必须大于等于m,并且小于等于n,如果有多个,则要求从小到大排列在一行内输出,之间用一个空格隔开;

如果给定的范围内不存在水仙花数,则输出no;

每个测试实例的输出占一行。

Sample Input

100 120

300 380

Sample Output

no

370 371

Author

lcy

Source

C语言程序设计练习(二)

#include

int main()

{

int m, n, k1, k2, k3, count;

while(scanf("%d %d", &m, &n) != EOF)

{

for(count = 0; m <= n; ++m)

{

k1 = m / 100;

k2 = (m - 100 * k1) / 10;

k3 = (m -100 * k1 -10 * k2);

if(m == k1*k1*k1 + k2*k2*k2 + k3*k3*k3)

{

if(count != 0)

{

printf(" ");

}

printf("%d", m);

count++;

}

}

if(count == 0)

printf("no\n");

else

printf("\n");

}

return 0;

}

2012 素数判定

Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)

Total Submission(s) : 29 Accepted Submission(s) : 15

Font: Times New Roman | Verdana | Georgia

Font Size: ←→

Problem Description

对于表达式n^2+n+41,当n在(x,y)范围内取整数值时(包括x,y)(-39<=x

Input

输入数据有多组,每组占一行,由两个整数x,y组成,当x=0,y=0时,表示输入结束,该行不做处理。

Output

对于每个给定范围内的取值,如果表达式的值都为素数,则输出"OK",否则请输出“Sorry”,每组输出占一行。

Sample Input

0 1

0 0

Sample Output

OK

Author

lcy

Source

C语言程序设计练习(二)

Statistic | Submit | Back

#include

int main()

{

int x, y, sum, i, count, n;

while(scanf("%d %d", &x, &y) != EOF && (x!=0 || y!= 0))

{

count = 0;

for(n = x; n <= y; ++n)

{

sum = n * n + n + 41;

for(i = 2; i * i <= sum; ++i)

{

if(sum % i == 0)

count = 1;

}

}

if(count == 0)

printf("OK\n");

else

printf("Sorry\n");

}

return 0;

}

2013蟠桃记

Time Limit: 2000/1000 MS (Java/Others) Memory Limit:

65536/32768 K (Java/Others)

Total Submission(s): 11490 Accepted Submission(s): 8803

Problem Description

喜欢西游记的同学肯定都知道悟空偷吃蟠桃的故事,你们一定都觉得这猴子太闹腾了,其实你们是有所不知:悟空是在研究一个数学问题!什么问题?他研究的问题是蟠桃一共有多少个!

不过,到最后,他还是没能解决这个难题,呵呵^-^

当时的情况是这样的:

第一天悟空吃掉桃子总数一半多一个,第二天又将剩下的桃子吃掉一半多一个,以后每天吃掉前一天剩下的一半多一个,到第n天准备吃的时候只剩下一个桃子。聪明的你,请帮悟空算一下,他第一天开始吃的时候桃子一共有多少个呢?

Input

输入数据有多组,每组占一行,包含一个正整数n(1

Output

对于每组输入数据,输出第一天开始吃的时候桃子的总数,每个测试实例占一行。

Sample Input

2

4

Sample Output

4

22

#include

long pantao (int n){

return n == 1 ? 1 : 2 + 2 * pantao(n-1);

}

int main(){

int n;

while(scanf("%d", &n) != EOF){

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

}

return 0;

}

2014青年歌手大奖赛_评委会打分

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 17419 Accepted Submission(s): 7801

Problem Description

青年歌手大奖赛中,评委会给参赛选手打分。选手得分规则为去掉一个最高分和一个最低分,然后计算平均得分,请编程输出某选手的得分。

Input

输入数据有多组,每组占一行,每行的第一个数是n(2

Output

对于每组输入数据,输出选手的得分,结果保留2位小数,每组输出占一行。

Sample Input

3 99 98 97

4 100 99 98 97

Sample Output

98.00

98.50

Author

lcy

Source

C语言程序设计练习(三)

Recommend

lcy

#include

int main ()

{

int n,i;

double sum, averge, max, min, score;

while(scanf("%d",&n)!=EOF)

{

scanf("%lf",&score);

max = score;

min = score;

sum = score;

for(i=2;i<=n;i++)

{

scanf("%lf",&score);

if(score>max)

max=score;

if(score

min=score;

sum += score;

}

averge=(sum-max-min)/(n-2);

printf("%.2f\n",averge);

}

return 0;

}

2016数据交换输出

Font: Times New Roman | Verdana | Georgia

Font Size: ←→

Problem Description

输入n(n<100)个数,找出其中最小的数,将它与最前面的数交换后输出这些数。

Input

输入数据有多组,每组占一行,每行的开始是一个整数n,表示这个测试实例的数值的个数,跟着就是n个整数。n=0表示输入的结束,不做处理。

Output

对于每组输入数据,输出交换后的数列,每组输出占一行。

Sample Input

4 2 1 3 4

5 5 4 3 2 1

Sample Output

1 2 3 4

1 4 3

2 5

Author

lcy

Source

C语言程序设计练习(三)

Statistic | Submit | Back

#include

int main(){

int n, i, k, a[100],min, temp;

while(scanf("%d", &n) != EOF && n != 0){

scanf("%d", &a[0]);

min = a[0];

k = 0;

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

scanf("%d", &a[i]);

if(a[i] < min){

min = a[i];

k = i;

}

}

temp = a[0];

a[0] = min;

a[k] = temp;

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

{

if(i !=1)

printf(" ");

printf("%d", a[i-1]);

}

printf("\n");

}

return 0;

}

2017字符串统计

Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)

Total Submission(s) : 65 Accepted Submission(s) : 33

Font: Times New Roman | Verdana | Georgia

Font Size: ←→

Problem Description

对于给定的一个字符串,统计其中数字字符出现的次数。

Input

输入数据有多行,第一行是一个整数n,表示测试实例的个数,后面跟着n行,每行包括一个由字母和数字组成的字符串。

Output

对于每个测试实例,输出该串中数值的个数,每个输出占一行。

Sample Input

2

asdfasdf123123asdfasdf

asdf111111111asdfasdfasdf

Sample Output

6

9

Author

lcy

Source

C语言程序设计练习(三)

Statistic | Submit | B

#include

int main(){

int num, n, i;

char line;

scanf("%d", &n);

getchar();

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

num = 0;

for(; (line = getchar()) != '\n'; ){

if(line >='0' && line <= '9')

num++;

}

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

}

return 0;

}

2024C语言合法标识符

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 11613 Accepted Submission(s): 4840

Problem Description

输入一个字符串,判断其是否是C的合法标识符。

Input

输入数据包含多个测试实例,数据的第一行是一个整数n,表示测试实例的个数,然后是n 行输入数据,每行是一个长度不超过50的字符串。

Output

对于每组输入数据,输出一行。如果输入数据是C的合法标识符,则输出"yes",否则,输出“no”。

Sample Input

3

12ajf

fi8x_a

ff ai_2

Sample Output

no

yes

no

Author

lcy

Source

C语言程序设计练习(四)

Recommend

lcy

#include

int main(){

int n, i, j,frag;

char line[50];

while(scanf("%d", &n) != EOF){

getchar();

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

j = 0; frag = 0;

while((line[j] = getchar()) != '\n'){

if(!((line[j]=='_')||(line[j]>='0'&&line[j]<='9')||(line[j]>='A'&&line[j]<='Z')||(line[j]>='a'&&line[j]<= 'z')))

frag = 1;

if(line[0] >= '0' && line[0] <= '9'){

frag = 1;

}

++j;

}

if(frag == 0)

printf("yes");

else

printf("no");

printf("\n");

}

}

return 0;

}

2025 查找最大元素

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 10087 Accepted Submission(s): 5399

Problem Description

对于输入的每个字符串,查找其中的最大字母,在该字母后面插入字符串“(max)”。

Input

输入数据包括多个测试实例,每个实例由一行长度不超过100的字符串组成,字符串仅由大小写字母构成。

Output

对于每个测试实例输出一行字符串,输出的结果是插入字符串“(max)”后的结果,如果存在多个最大的字母,就在每一个最大字母后面都插入"(max)"。

Sample Input

abcdefgfedcba

xxxxx

Sample Output

abcdefg(max)fedcba

x(max)x(max)x(max)x(max)x(max) Author

lcy

Source

C语言程序设计练习(四)

#include

int main(){

int i, max, n, j, line[100];

while((line[0]=getchar()) != EOF){

max = line[0];

i = 1;

for(; (line[i] = getchar()) != '\n'; ++i){

if(line[i] > max) {

max = line[i];

}

}

n = i;

for(j = 0; j <= n; ++j){

if(line[j] == max){

printf("%c", line[j]);

printf("(max)");

}

else

printf("%c", line[j]);

}

//printf("\n");

}

return 0;

}

2081手机短号

Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 6198 Accepted Submission(s): 3955

Problem Description

大家都知道,手机号是一个11位长的数字串,同时,作为学生,还可以申请加入校园网,如果加入成功,你将另外拥有一个短号。假设所有的短号都是是6+手机号的后5位,比如号码为135********的手机,对应的短号就是645678。

现在,如果给你一个11位长的手机号码,你能找出对应的短号吗?

Input

输入数据的第一行是一个N(N <= 200),表示有N个数据,接下来的N行每一行为一个11位的手机号码。

Output

输出应包括N行,每行包括一个对应的短号,输出应与输入的顺序一致。

Sample Input

2

135********

137********

Sample Output

645678

654321

Source

2006/1/15 ACM程序设计期末考试

#include

#include

int main () {

int n, i;

char a[11];

scanf("%d", &n);

getchar();

while(n--){

for(i = 0; i < 6; ++i)

getchar();

gets(a);

printf("6%s\n", a);

}

return 0;

}

2096小明A+B

Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 10221 Accepted Submission(s): 4650

Problem Description

小明今年3岁了, 现在他已经能够认识100以内的非负整数, 并且能够进行100以内的非负整数的加法计算.

对于大于等于100的整数, 小明仅保留该数的最后两位进行计算, 如果计算结果大于等于100, 那么小明也仅保留计算结果的最后两位.

例如, 对于小明来说:

1) 1234和34是相等的

2) 35+80=15

给定非负整数A和B, 你的任务是代表小明计算出A+B的值.

Input

输入数据的第一行为一个正整数T, 表示测试数据的组数. 然后是T组测试数据. 每组测试数据包含两个非负整数A和B(A和B均在int型可表示的范围内).

Output

对于每组测试数据, 输出小明A+B的结果.

Sample Input

2

35 80

(完整版)杭电acm部分答案

Problem Description Calculate A + B. Input Each line will contain two integers A and B. Process to end of file. Output For each case, output A + B in one line. Sample Input 1 1 Sample Output 2 #include void main() { int a,b; while(scanf("%d %d",&a,&b)!=EOF) { printf("%d\n",a+b); } } Problem Description Hey, welcome to HDOJ(Hangzhou Dianzi University Online Judge). In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n. Input The input will consist of a series of integers n, one integer per line. Output For each case, output SUM(n) in one line, followed by a blank line. You may assume the result will be in the range of 32-bit signed integer. Sample Input 1 100 Sample Output

杭州电子科技大学OJ题目分类

杭州电子科技大学OJ题目分类 1001 整数求和水题 1002 C语言实验题——两个数比较水题 1003 1、2、3、4、5... 简单题 1004 渊子赛马排序+贪心的方法归并 1005 Hero In Maze 广度搜索 1006 Redraiment猜想数论:容斥定理 1007 童年生活二三事递推题 1008 University 简单hash 1009 目标柏林简单模拟题 1010 Rails 模拟题(堆栈) 1011 Box of Bricks 简单题 1012 u Calculate e 简单数学计算 1013 STAMPS 搜索or动态规划 1014 Border 模拟题 1015 Simple Arithmetics 高精度计算 1016 Shoot-out 博弈+状态压缩DP 1017 Tour Guide 1018 Card Trick 简单题 1019 Necklace Decomposition 贪心 1020 Crashing Robots 模拟题 1021 Electrical Outlets 简单题 1022 Watchdog 简单题 1023 Taxi Cab Scheme 图论:最小路径覆盖--->最大二分匹配1024 Pseudo-random Numbers 数论 1025 Card Game Cheater 简单题 1026 Investment 动态规划 1027 Pipes 1028 SETI 数学:高斯消元法 1029 Minimax Triangulation 计算几何 1030 Unequalled Consumption 母函数 1031 Declaration of Content 1032 Laserbox 搜索:DFS 1033 Bowlstack 1034 Pesky Heroes 1035 Reduced ID Numbers 暴力 1036 Tantrix 1037 Guardian of Decency 图论:匈牙利算法求二分图的最大匹配1038 Up the Stairs 简单数学题 1039 Sudoku 搜索:DFS 1040 The SetStack Computer 1041 Pie 二分法 1042 Ticket to Ride 动态规划 1043 The Bookcase 动态规划

杭电ACM水题题目及代码

1001 #include int main() { int i,a,j;double sum; while(scanf("%d",&a)!=EOF) { sum=0; for(j=1;j<=a;j++) { sum+=j; } printf("%.0lf\n\n",sum); } return 0; } 1002 A + B Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 69615 Accepted Submission(s): 12678 Problem Description I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.

Input The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line consists of two positive integers, A and B. Notice that the integers are very large, that means you should not process them by using 32-bit integer. You may assume the length of each integer will not exceed 1000. Output For each test case, you should output two lines. The first line is "Case #:", # means the number of the test case. The second line is the an equation "A + B = Sum", Sum means the result of A + B. Note there are some spaces int the equation. Output a blank line between two test cases. Sample Input 2 1 2 112233445566778899 998877665544332211 Sample Output Case 1: 1 + 2 = 3 Case 2: 112233445566778899 + 998877665544332211 = 1111111111111111110 Author Ignatius.L #include #include int main(){ char str1[1001], str2[1001]; int t, i, len_str1, len_str2, len_max, num = 1, k; scanf("%d", &t); getchar(); while(t--){ int a[1001] = {0}, b[1001] = {0}, c[1001] = {0}; scanf("%s", str1); len_str1 = strlen(str1);

杭电OJ题目分类

杭州电子科技大学OJ题目分类The Soul with Bone .: 1001 整数求和水题 1002 C语言实验题——两个数比较水题 1003 1、2、3、4、5... 简单题 1004 渊子赛马排序+贪心的方法归并 1005 Hero In Maze 广度搜索 1006 Redraiment猜想数论:容斥定理 1007 童年生活二三事递推题 1008 University 简单hash 1009 目标柏林简单模拟题 1010 Rails 模拟题(堆栈) 1011 Box of Bricks 简单题 1012 IMMEDIATE DECODABILITY Huffman编码 1013 STAMPS 搜索or动态规划 1014 Border 模拟题 1015 Simple Arithmetics 高精度计算 1016 Shoot-out 博弈+状态压缩DP 1017 Tour Guide 1018 Card Trick 简单题 1019 Necklace Decomposition 贪心

1020 Crashing Robots 模拟题 1021 Electrical Outlets 简单题 1022 Watchdog 简单题 1023 Taxi Cab Scheme 图论:最小路径覆盖--->最大二分匹配1024 Pseudo-random Numbers 数论 1025 Card Game Cheater 简单题 1026 Investment 动态规划 1027 Pipes 1028 SETI 数学:高斯消元法 1029 Minimax Triangulation 计算几何 1030 Unequalled Consumption 母函数 1031 Declaration of Content 1032 Laserbox 搜索:DFS 1033 Bowlstack 1034 Pesky Heroes 1035 Reduced ID Numbers 暴力 1036 Tantrix 1037 Guardian of Decency 图论:匈牙利算法求二分图的最大匹配1038 Up the Stairs 简单数学题 1039 Sudoku 搜索:DFS 1040 The SetStack Computer 1041 Pie 二分法

杭电acm部分题目及答案答案

自己刷的题 这是我在杭电做题的记录,希望我的分享对你有帮助!!! 1001 Sum Problem***********************************************************1 1089 A+B for Input-Output Practice (I)********************************2 1090 A+B for Input-Output Practice (II)********************************5 1091A+B for Input-Output Practice (III)****************************************7 1092A+B for Input-Output Practice (IV)********************************8 1093 A+B for Input-Output Practice (V)********************************10 1094 A+B for Input-Output Practice (VI)***************************************12 1095A+B for Input-Output Practice (VII)*******************************13 1096 A+B for Input-Output Practice (VIII)******************************15 How to Type***************************************************************16 1001 Sum Problem Problem Description Hey, welcome to HDOJ(Hangzhou Dianzi University Online Judge). In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n. Input The input will consist of a series of integers n, one integer per line. Output For each case, output SUM(n) in one line, followed by a blank line. You may assume the result will be in the range of 32-bit signed integer.

整理出ACM所有题目及答案

1111111杭电: 1000 A + B Problem (4) 1001 Sum Problem (5) 1002 A + B Problem II (6) 1005 Number Sequence (8) 1008 Elevator (9) 1009 FatMouse' Trade (11) 1021 Fibonacci Again (13) 1089 A+B for Input-Output Practice (I) (14) 1090 A+B for Input-Output Practice (II) (15) 1091 A+B for Input-Output Practice (III) (16) 1092 A+B for Input-Output Practice (IV) (17) 1093 A+B for Input-Output Practice (V) (18) 1094 A+B for Input-Output Practice (VI) (20) 1095 A+B for Input-Output Practice (VII) (21) 1096 A+B for Input-Output Practice (VIII) (22) 1176 免费馅饼 (23) 1204 糖果大战 (25) 1213 How Many Tables (26) 2000 ASCII码排序 (32) 2001 计算两点间的距离 (34) 2002 计算球体积 (35) 2003 求绝对值 (36) 2004 成绩转换 (37) 2005 第几天? (38) 2006 求奇数的乘积 (40) 2007 平方和与立方和 (41) 2008 数值统计 (42) 2009 求数列的和 (43) 2010 水仙花数 (44) 2011 多项式求和 (46) 2012 素数判定 (47) 2014 青年歌手大奖赛_评委会打分 (49) 2015 偶数求和 (50) 2016 数据的交换输出 (52) 2017 字符串统计 (54) 2019 数列有序! (55) 2020 绝对值排序 (56) 2021 发工资咯:) (58) 2033 人见人爱A+B (59) 2037 今年暑假不AC (61) 2039 三角形 (63) 2040 亲和数 (64)

杭电ACM试题详细分类,杭电oj详细分类,hdu详细分类,详细,ACM.doc

杭电ACM试题分类 枚举 1002 10041013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 10471048 1049 1050 1057 1062 1063 1064 1070 1073 1075 1082 1083 1084 1088 11061107 1113 1117 1119 1128 1129 1144 1148 1157 1161 1170 1172 1177 11971200 1201 1202 1205 1209 1212(大数取模)1216 (链表)1218 1219 1225 1228 12291230 1234 1235 1236 1237 1239 1250 1256 1259 1262 1263 1265 1266 1276 1279 1282 1283 1287 1296 1302 1303 1304 1305 1306 1309 1311 1314 搜索,递归求解 1010 1016 1026 1043(双广)1044 (BFS+DFS) 1045 1067 1072 1104 1175 1180 1195 1208 1226 1238 1240 1241 1242 1258 1271 1312 1317 动态规划 1003 1024 1025 1028 1051 1058 1059 1069 1074 1078 1080 1081 1085 1087 1114 1158 1159 1160 1171 1176 1181 1203 1224 1227 1231 1244 1248 1253 1254 1283 1300 数学,递推,规律 1005 1006 1012 1014 1018 1019 1021 1023 1027 1030 1032 1038 1041 1046 1059 1060 1061 1065 1066 1071(微积分)1097 1098 1099 1100 1108 1110 1112 1124 1130 1131 1132 1134 1141 1143 1152 1155(物理题)1163 1165 1178 1194 1196(lowbit) 1210 1214 1200 1221 1223 1249 1261 1267 1273 1290 1291 1292 1294 1297 1313 1316 数论 1164 1211 1215 1222 1286 1299 计算几何 1086 1115 1147

ACM入门十题(杭电oj)

ACM入门(杭电oj) Hdu 1000 #include #include int main() { int a,b; while(scanf("%d%d",&a,&b)!=EOF) { printf("%d\n",a+b); } } Hdu 1001 #include #include int main() { int n; while(scanf("%d",&n)!=EOF) { printf("%I64d\n\n",(__int64)(1+n)*n/2); } } Hdu 1002 #include #include #include char str1[1005],str2[10005]; int main() { int ca,count=0; scanf("%d",&ca); while(ca--) { scanf("%s%s",str1,str2); int a[1005],i,j; memset(a,0,sizeof(a)); for(i=strlen(str1)-1,j=0;i>=0;i--,j++) a[j]=str1[i]-'0'; for(i=strlen(str2)-1,j=0;i>=0;i--,j++) {

a[j]=a[j]+str2[i]-'0'; a[j+1]=a[j+1]+a[j]/10; a[j]=a[j]%10; } count++; printf("Case %d:\n",count); printf("%s + %s = ",str1,str2); int flag=0; for(i=1004;i>=0;i--) if(flag||a[i]) { printf("%d",a[i]); flag=1; } printf("\n"); if(ca!=0) printf("\n"); } } Hdu 1003 #include #include int a[100005],sum[100005]; int main() { int ca,count=0; scanf("%d",&ca); while(ca--) { int n,i; scanf("%d",&n); for(i=1;i<=n;i++) scanf("%d",&a[i]); sum[1]=a[1]; int r=1,max=a[1]; for(i=2;i<=n;i++) { if(sum[i-1]>0) { sum[i]=sum[i-1]+a[i]; if(sum[i]>max) { max=sum[i]; r=i;

杭电题目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) 姓名:郑春杰 班级:电商1001 学号:34

完整word版杭电ACM试题答案

【杭电ACM1000】 A + B Problem Problem Description Calculate A + B. Input Each line will contain two integers A and B. Process to end of file. Output For each case, output A + B in one line. Sample Input 1 1 Sample Output 2 # include int main() { int a, b; while(scanf(%d%d, &a, &b)!=EOF) printf(%d\n, a+b); return 0; } 【杭电ACM1001】 Sum Problem Problem Description Hey, welcome to HDOJ(Hangzhou Dianzi University Online Judge). In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n.

Input The input will consist of a series of integers n, one integer per line. Output For each case, output SUM(n) in one line, followed by a blank line. You may assume the result will be in the range of 32-bit signed integer. Sample Input 1 100 Sample Output 1 5050 # include int main() { int n, i, sum = 0; while(scanf(%d, &n)!=EOF) { for(i=1; i<=n; ++i) sum = sum + i; printf(%d\n\n, sum); sum = 0; } return 0; } 【杭电ACM1002】 A + B Problem II Problem Description I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B. Input The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line consists of two positive integers, A and B. Notice that the integers

ACM部分练习题目答案

ACM部分习题答案: A + B Problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 100972 Accepted Submission(s): 33404 Problem Description Calculate A + B. Input Each line will contain two integers A and B. Process to end of file. Output For each case, output A + B in one line. Sample Input 1 1 Sample Output 2 # include Int main() {int x,y,s; while(scanf("%d %d",&x,&y)!=EOF) {s=x+y; printf("%d\n",s);} return 0; } Sum Problem Time Limit: 1000/500 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 85964 Accepted Submission(s): 19422 Problem Description Hey, welcome to HDOJ(Hangzhou Dianzi University Online Judge). In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n. Input The input will consist of a series of integers n, one integer per line. Output For each case, output SUM(n) in one line, followed by a blank line. You may assume the result will be in the range of 32-bit signed integer. Sample Input 1 100 Sample Output 1 5050 # include int main() {int n; long int s;

杭电ACM部分题答案

1000A + B Problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 158161 Accepted Submission(s): 50186 Problem Description Calculate A + B. Input Each line will contain two integers A and B. Process to end of file. Output For each case, output A + B in one line. Sample Input 1 1 Sample Output 2 Author HDOJ Statistic | Submit | Discuss | Note #include int main() { int a,b; while(scanf("%d %d",&a,&b)!=EOF) printf("%d\n",a+b); }

1002A + B Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 84367 Accepted Submission(s): 15966 Problem Description I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B. Input The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line consists of two positive integers, A and B. Notice that the integers are very large, that means you should not process them by using 32-bit integer. You may assume the length of each integer will not exceed 1000. Output For each test case, you should output two lines. The first line is "Case #:", # means the number of the test case. The second line is the an equation "A + B = Sum", Sum means the result of A + B. Note there are some spaces int the equation. Output a blank line between two test cases. Sample Input 2 1 2 112233445566778899 998877665544332211 Sample Output Case 1: 1 + 2 = 3 Case 2: 112233445566778899 + 998877665544332211 = 1111111111111111110 Author Ignatius.L Statistic | Submit | Discuss | Note

杭电题目acm答案

选修课考试作业 1001 Sum Problem ............................................................................................ 错误!未定义书签。1089 A+B for Input-Output Practice (I) .......................................................... 错误!未定义书签。1090 A+B for Input-Output Practice (II) ......................................................... 错误!未定义书签。1091 A+B for Input-Output Practice (III) ........................................................ 错误!未定义书签。1092 A+B for Input-Output Practice (IV) ........................................................... 错误!未定义书签。1093 A+B for Input-Output Practice (V) ......................................................... 错误!未定义书签。1094 A+B for Input-Output Practice (VI) ........................................................ 错误!未定义书签。1095 A+B for Input-Output Practice (VII) .......................................................... 错误!未定义书签。1096 A+B for Input-Output Practice (VIII) ...................................................... 错误!未定义书签。' 2000 ASCII码排序 ............................................................................................ 错误!未定义书签。2001计算两点间的距离.................................................................................. 错误!未定义书签。2002计算球体积 ............................................................................................. 错误!未定义书签。2003求绝对值 ................................................................................................. 错误!未定义书签。2004成绩转换 ................................................................................................. 错误!未定义书签。2005第几天 ..................................................................................................... 错误!未定义书签。2006求奇数的乘积 ......................................................................................... 错误!未定义书签。2007平方和与立方和...................................................................................... 错误!未定义书签。2008数值统计 ................................................................................................. 错误!未定义书签。2009求数列的和 ............................................................................................. 错误!未定义书签。~ 2010水仙花数 ................................................................................................. 错误!未定义书签。2011多项式求和 ............................................................................................. 错误!未定义书签。2012素数判定 ................................................................................................. 错误!未定义书签。2014青年歌手大奖赛_评委会打分................................................................ 错误!未定义书签。2015偶数求和 ................................................................................................. 错误!未定义书签。2016数据的交换输出...................................................................................... 错误!未定义书签。2017字符串统计 ............................................................................................. 错误!未定义书签。2019数列有序! ................................................................................................ 错误!未定义书签。2020绝对值排序.............................................................................................. 错误!未定义书签。2021发工资咯:)............................................................................................ 错误!未定义书签。: 2033人见人爱A+B .......................................................................................... 错误!未定义书签。2039三角形 ..................................................................................................... 错误!未定义书签。2040亲和数 ..................................................................................................... 错误!未定义书签。 姓名:郑春杰 班级:电商1001

杭电ACM博弈题合集

hdu博弈,这些题都不难。 属于博弈简单题。 hdu1846巴什博弈,n%(m+1)==0先手必败。 #include #include #include #include #include using namespace std; int main() { int n,a,b; scanf("%d",&n); while(n--) { scanf("%d%d",&a,&b); if(a%(b+1)==0) printf("second\n"); else printf("first\n"); } return 0; } hdu1847 只要留下两类都是2的指数幂,就是必输状态,然后找规律,发现这两类的和为3的倍数。即有下面的结论。 #include #include #include using namespace std; int main() { int n; while(scanf("%d",&n)!=EOF) { if(n%3==0) printf("Cici\n"); else printf("Kiki\n"); } return 0; } hdu1848 #include #include

#include #include using namespace std; #define N 1005 int f[N]; int sg[N]; void fun() { int i; f[0]=1; f[1]=1; f[2]=2; for(i=3;;i++) { f[i]=f[i-1]+f[i-2]; if(f[i]>1000) break; } } int dfs(int v) { int i; if(sg[v]!=-1) return sg[v]; bool visit[N]={0}; for(i=1;i<16;i++) { if(v>=f[i]) { int temp=dfs(v-f[i]); visit[temp]=1; } } for(i=0;visit[i];i++); return sg[v]=i; } int main() { fun(); int m,n,p; while(scanf("%d%d%d",&m,&n,&p),m||n||p) { memset(sg,-1,sizeof(sg)); int ans;

相关主题
文本预览
相关文档 最新文档