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

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

举报
开通vip

杭电acm部分题目及答案答案杭电acm部分题目及答案答案 自己刷的题 这是我在杭电做题的记录,希望我的分享对你有 帮助~~~ 1001 Sum Problem***********************************************************1 1089 A+B for Input-Output Practice (I)********************************2 1090 A+B for Input-Output Practice (II)******************...

杭电acm部分题目及答案答案
杭电acm部分 快递公司问题件快递公司问题件货款处理关于圆的周长面积重点题型关于解方程组的题及答案关于南海问题 目及答案答案 自己刷的题 这是我在杭电做题的记录,希望我的分享对你有 帮助~~~ 1001 Sum Problem***********************************************************1 1089 A+B for Input-Output Practice (I)********************************2 1090 A+B for Input-Output Practice (II)********************************5 1091 A+B for Input-Output Practice (III)****************************************7 1092 A+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 1095 A+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. Sample Input 1 100 Sample Output 1 5050 Author DOOM III 解答: #include main() { int n,i,sum; sum=0; while((scanf("%d",&n)!=-1)) { sum=0; for(i=0;i<=n;i++) sum+=i; printf("%d\n\n",sum); } } 1089 A+B for Input-Output Practice (I) Problem Description Your task is to Calculate a + b. Too easy?! Of course! I specially designed the problem for acm beginners. You must have found that some problems have the same titles with this one, yes, all these problems were designed for the same aim. 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 10 20 Sample Output 6 30 Author lcy Recommend JGShining 解答: #include main() { int a,b; while(scanf("%d%d",&a,&b)!=EOF) printf("%d\n",a+b); } 1090 A+B for Input-Output Practice (II) Problem Description Your task is to Calculate a + b. Input Input contains an integer N in the first line, and then N lines follow. Each line consists of a pair 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 2 1 5 10 20 Sample Output 6 30 Author lcy Recommend JGShining 解答: #include #define M 1000 void main() { int a ,b,n,j[M],i; //printf("please input n:\n"); scanf("%d",&n); for(i=0;i main() { int a,b; scanf("%d %d",&a,&b); while(!(a==0&&b==0)) { printf("%d\n",a+b); scanf("%d %d",&a,&b); } } 1092 A+B for Input-Output Practice (IV) Problem Description Your task is to Calculate the sum of some integers. Input Input contains multiple test cases. Each test case contains a integer N, and then N integers follow in the same line. A test case starting with 0 terminates the input and this test case is not to be processed. Output For each group of input integers you should output their sum in one line, and with one line of output for each line in input. Sample Input 4 1 2 3 4 5 1 2 3 4 5 0 Sample Output 10 15 Author lcy Recommend JGShining 解答: #include int main() { int n,sum,i,t; while(scanf("%d",&n)!=EOF&&n!=0) { sum=0; for(i=0;i main() { int n,a,b,i,j,sum; sum=0; while(scanf("%d\n",&n)!=-1) { for(i=0;i main() { int n,a,b,i,j,sum; sum=0; while(scanf("%d\n",&n)!=-1) { for(j=0;j main() { int a,b; while(scanf("%d%d",&a,&b)!=EOF) printf("%d\n\n",a+b); } 1096 A+B for Input-Output Practice (VIII) Problem Description Your task is to calculate the sum of some integers. Input Input contains an integer N in the first line, and then N lines follow. Each line starts with a integer M, and then M integers follow in the same line. Output For each group of input integers you should output their sum in one line, and you must note that there is a blank line between outputs. Sample Input 3 4 1 2 3 4 5 1 2 3 4 5 3 1 2 3 Sample Output 10 15 6 Author lcy 第 15 页 共 20 页 杭州电子科技大学acm习题精选 Recommend JGShining 解答: int main() { int a,b,i,j,l[1000],k; scanf("%d",&i); getchar(); for(j=1;j<=i;j++) l[j]=0; for(j=1;j<=i;j++) { scanf("%d",&a); getchar(); for(k=1;k<=a;k++) { scanf("%d",&b); getchar(); l[j]+=b; } } for(j=1;j<=i-1;j++) printf("%d\n\n",l[j]); printf("%d\n",l[i]); } How to Type Problem Description Pirates have finished developing the typing software. He called Cathy to test his typing software. She is good at thinking. After testing for several days, she finds that if she types a string by some ways, she will type the key at least. But she has a bad habit that if the caps lock is on, she must turn off it, after she finishes typing. Now she wants to know the smallest times of typing the key to finish typing a string. Input The first line is an integer t (t<=100), which is the number of test case in the input file. For each test case, there is only one string which consists of lowercase letter and upper case letter. The length of the string is at most 100. Output For each test case, you must output the smallest times of typing the key to finish typing this string. Sample Input 3 第 16 页 共 20 页 杭州电子科技大学acm习题精选 Pirates HDUacm HDUACM Sample Output 8 8 8 第 17 页 共 20 页 杭州电子科技大学acm习题精选 #include #include #define MAX 200 int arr[MAX][4]; char str[MAX]; int letter(char ch) { if(ch>='A'&&ch<='Z') return 1; return 0; } void proc() { int i; int tmp,min; int len=strlen(str); for(i=0;iarr[i-1][2]+1||!arr[i][0]) arr[i][0]=arr[i-1][2]+1; if(arr[i][3]>arr[i-1][2]+3||!arr[i][3]) arr[i][3]=arr[i-1][2]+3; } if(arr[i-1][3]) { if(arr[i][1]>arr[i-1][3]+2||!arr[i][1]) arr[i][1]=arr[i-1][3]+2; if(arr[i][2]>arr[i-1][3]+2||!arr[i][2]) arr[i][2]=arr[i-1][3]+2; } } else { if(arr[i-1][0]){ arr[i][1]=arr[i-1][0]+2; arr[i][2]=arr[i-1][0]+2;} if(arr[i-1][1]){ arr[i][0]=arr[i-1][1]+1; arr[i][3]=arr[i-1][1]+3;} if(arr[i-1][2]) 第 18 页 共 20 页 杭州电子科技大学acm习题精选 { if(arr[i][1]>arr[i-1][2]+2||!arr[i][1]) arr[i][1]=arr[i-1][2]+2; if(arr[i][2]>arr[i-1][2]+2||!arr[i][2]) arr[i][2]=arr[i-1][2]+2; } if(arr[i-1][3]) { if(arr[i][0]>arr[i-1][3]+1||!arr[i][0]) arr[i][0]=arr[i-1][3]+1; if(arr[i][3]>arr[i-1][3]+3||!arr[i][3]) arr[i][3]=arr[i-1][3]+3; } } } } min=3*MAX; if(letter(str[len-1])) { if(arr[len-1][0]){ tmp=arr[len-1][0]+1; if(tmp
本文档为【杭电acm部分题目及答案答案】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_511210
暂无简介~
格式:doc
大小:44KB
软件:Word
页数:21
分类:企业经营
上传时间:2017-09-02
浏览量:74