Contest - 2014常熟理工学院第四届软件大赛

来源:互联网 发布:飞鱼网络电视 编辑:程序博客网 时间:2024/04/20 21:30

Contest - 2014常熟理工学院第四届软件大赛

Start time:  2014-11-22 08:00:00.0  End time:  2014-11-22 12:00:00.0
Current System Time:  2014-12-06 12:24:37.052  Contest Status:   Ended

常熟理工学院第四届软件设计与开发大赛暨第六届全国软件专业人才设计和信息技术专业人才大赛(个人赛)校内选拔赛 
Problem A:

手机短号

Time Limit:1000MS  Memory Limit:32768K
Total Submit:483 Accepted:91

Description

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

Input

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

Output

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

Sample Input

21351234567813787654321

Sample Output

645678654321

Source

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

源代码:
  • #include <stdio.h>#include <stdlib.h>int main(){    int n,i,k;    char str[12];    scanf("%d",&n);    while(n--){        k=1;        scanf("%s",str);        str[0]=6+'0';        for(i=6;i<=10;i++)            str[k++]=str[i];        str[k]='\0';        printf("%s",str);        printf("\n");    }    return 0;}

Problem B:

三角形

Time Limit:1000MS  Memory Limit:32768K
Total Submit:684 Accepted:77

Description

这是一个简单的任务:
假设告诉你三个正整数A,B和C (0<a,b,c<10000),它们分别表示三条边的长度,请判断这三条边是否能够组成一个合法的三角形。< font="">

Input

输入数据的第一行是一个正整数N,表示有N组测试数据,然后是N行数据,每行包含三个整数A,B和C。

Output

对于每组数据,如果能够组成合法三角形,请输出Yes,否则请输出No。

Sample Input

33 4 43 4 53 4 8

Sample Output

YesYesNo

Source

ACM程序设计期末考试(晚上班)

源代码:
  • #include <stdio.h>#include <stdlib.h>int issjx(int a,int b,int c){    if(a+b>c)        if(a+c>b)           if(b+c>a)              return 1;    return 0;}int main(){    int n;    scanf("%d",&n);    while(n--){        int a,b,c;        scanf("%d%d%d",&a,&b,&c);        if(issjx(a,b,c)){            printf("Yes\n");        }        else printf("No\n");    }    return 0;}

Problem C:

求最大公约数

Time Limit:1000MS  Memory Limit:65536K
Total Submit:197 Accepted:156

Description

请写一程序求出2个数的GCD(最大公约数)输入包含好几个测试样例,每个测试样例一行,包含两上整数a,b;0 0 代表输入结束。对每行输入,输出这2个数的GCD

Input

Input contains multiple test cases. Each test case contains a pair of integers a and b, one pair of integers per line. A test case containing 0 0 terminates the input and this test case is not to be processed

Output

For each pair of input integers a and b you should output the GCD of a and b in one line, and with one line of output for each line in input.


Sample Input

12 3625 240 0

Sample Output

GCD(12,36)=12GCD(25,24)=1

Source


源代码:
  • #include <stdio.h>#include <stdlib.h>int GCD(int a ,int b){    int q;    q=a%b;    while(q!=0){        a=b;        b=q;        q=a%b;    }    return b;}int main(){    int a,b,gcd;    while(scanf("%d%d",&a,&b)!=EOF){        if(a==0&&b==0)            break;        gcd=GCD(a,b);        printf("GCD(%d,%d)=%d\n",a,b,gcd);    }    return 0;}

Problem E:

佳佳的四则运算

Time Limit:1000MS  Memory Limit:32768K
Total Submit:60 Accepted:9

Description

佳佳是大一新生..考上大学以后..就给家里的弟弟补习数学..这天..佳佳出了十以内的四则运算给弟弟做...
以下是佳佳出的题目...请问题目的答案是多少?

Input

第一行输入一个整数n(1<=n<=10),表示有多少题目;
第二至(n+1)行,每行输入一个表达式s(1<=s的长度<=50);

Output

每输入一行输出一行答案,每一行输出一个整数表示本道题的答案.
(答案保留两位小数,表达式中只包含整数和+,-,*,/)

Sample Input

13+4/5*4-3=

Sample Output

3.20

Source

福州大学09数计C语言练习

源代码:
  • #include <stdio.h>#include <string.h>float compvalue(char *postexp){    struct{       float data[500];       int top;    }st;    float d,a,b,c;    st.top=-1;    while(*postexp!='\0'){        switch (*postexp) {        case '+':             a=st.data[st.top];             st.top--;             b=st.data[st.top];             st.top--;             c=a+b;             st.top++;             st.data[st.top]=c;             break;        case '-':             a=st.data[st.top];             st.top--;             b=st.data[st.top];             st.top--;             c=b-a;             st.top++;             st.data[st.top]=c;             break;        case '*':             a=st.data[st.top];             st.top--;             b=st.data[st.top];             st.top--;             c=a*b;             st.top++;             st.data[st.top]=c;             break;         case '/':             a=st.data[st.top];             st.top--;             b=st.data[st.top];             st.top--;             if(a!=0){                 c=b/a;                 st.top++;                 st.data[st.top]=c;             }             break;         default:            d=0;            while(*postexp>='0' && *postexp<='9'){                d=10*d+*postexp-'0';                postexp++;            }            st.top++;            st.data[st.top]=d;            break;        }        postexp++;    }    return (st.data[st.top]);}void trans(char *exp,char postexp[]){    struct{        char data[500];        int top;    } op;    int i=0;    op.top=-1;    while(*exp!='\0'){            switch (*exp){        case '(':             op.top++;op.data[op.top]=*exp;             exp++;             break;        case ')':             while(op.data[op.top]!='('){                 postexp[i++]=op.data[op.top];                 op.top--;             }             op.top--;             exp++;break;        case '+':        case '-':             while(op.top!=-1&&op.data[op.top]!='('){                 postexp[i++]=op.data[op.top];                 op.top--;             }             op.top++;op.data[op.top]=*exp;             exp++;             break;        case '*':        case '/':             while(op.data[op.top]=='*'||op.data[op.top]=='/'){                postexp[i++]=op.data[op.top];                op.top--;             }             op.top++;             op.data[op.top]=*exp;             exp++;             break;        case ' ':exp++; break;        default:             while(*exp>='0'&&*exp<='9') {                  postexp[i++]=*exp;                  exp++;             }             postexp[i++]='#';        }    }        while(op.top!=-1){            postexp[i++]=op.data[op.top];            op.top--;        }        postexp[i]='\0';}int main(){  char exp[500];  char postexp[500];  int n;  scanf("%d",&n);   while(n--){      scanf("%s",exp);      exp[strlen(exp)-1]='\0';      trans(exp,postexp);      printf("%.2f\n",compvalue(postexp));  }  return 0;}

Problem F:

美美逛街

Time Limit:1000MS  Memory Limit:32768K
Total Submit:233 Accepted:4

Description

美美是个大一新生,每个月妈妈给美美1000元生活费...
1000元其实说多不多说少不少..除了吃饭和买生活必须品,美美每个月还可以剩下不少钱..所以啊...美美打算在她喜欢的东西里挑一样买..可是东西的价格不一..美美的喜好度也不一样..所以啊..美美到底要挑哪一样呢?

Input

第一行输入一个整数m(100<=m<=1000),表示美美这个月吃饭和买生活必须品等花去的钱数..
第二行输入一个整数n(1<=n<=100),表示美美喜欢的东西的数目
第三至(n+2)行,每行输入两个整数a,b(1<=a<=1000,1<=b<=100),a表示这样东西的价格,b表示美美对这样东西的喜欢度.
(在钱足够的情况下....喜好度当然越高越好..)

Output

输出一行x,y,z,表示美美这个月可以买到的那件东西的价格,喜好度,和所剩的钱.
(如果买不到任何一样东西..则输出"Cry!")

Sample Input

5002501 99502 98100250 9840 96

Sample Output

Cry!50 98 850

Source

福州大学09数计C语言练习


源代码:
  • #include "stdio.h"typedef struct{    int money;    int love;}choose;int compare(void *_a,void *_b){    choose* a = (choose*)_a;    choose* b = (choose*)_b;    return b->love-a->love;}int main(){    int n;    int num;    choose c[100];    while(scanf("%d",&n)!=EOF)    {        scanf("%d",&num);        int i;        for(i=0;i<num;i++){            scanf("%d%d",&c[i].money,&c[i].love);        }        qsort(c,num,sizeof(choose),compare);        n=1000-n;        for(i=0;i<num;i++)        {            if(n>=c[i].money){                break;            }        }        if(i!=num){            printf("%d %d %d\n",c[i].money,c[i].love,n-c[i].money);        }        else{             printf("Cry!\n");        }    }    return 0;}

Problem G:

柏柏的表白

Time Limit:1000MS  Memory Limit:32768K
Total Submit:398 Accepted:25

Description

柏柏是大一新生,和美美考进了同一间学校...因为偶然的机会..见到了美美..便一直暗恋她...终于..在同学的鼓励下..他鼓起了勇气..打算向美美表白...可是他不知道到底该如何向美美表白好呢?
是应该买束玫瑰花呢?还是应该写封情书呢?或者是应该发短信呢?又或者是再等等呢?......
他求助于身边的同学们...同学们也纷纷给他出了主意...

Input

第一行输入一个整数n(1<=n<=100),表示柏柏求助了n个同学
第二至(n+1)行,每行输入一串字符表示同学们对柏柏的建议..
分别是:
"Rose."(表示买玫瑰花)
"Letter."(表示写情书)
"Massage."(表示发短信)
"Wait."(表示再等等)

Output

输出一行字符,表示同学们对柏柏建议最多的一种选择.测试数据保证答案唯一。注意不要输出多余字符。

Sample Input

5Wait.Wait.Wait.Letter.Letter.

Sample Output

Wait.

Source

福州大学09数计C语言练习

源代码:
  • #include <stdio.h>#include <stdlib.h>#include <string.h>int main(){    int i,n,temp,flag,k=0;    int count[5];    char str[101][50];    while(scanf("%d",&n)!=EOF){            k=0;        for(i=0;i<n;i++)           scanf("%s",str[k++]);        for(i=0;i<5;i++)            count[i]=0;        for(i=0;i<n;i++){            if(strcmp(str[i],"Rose.")==0){                count[0]++;            }            else if(strcmp(str[i],"Letter.")==0){                count[1]++;            }            else if(strcmp(str[i],"Massage.")==0){                count[2]++;            }            else if(strcmp(str[i],"Wait.")==0){                count[3]++;            }        }        flag=0;        temp=0;        for(i=0;i<4;i++)            if(flag<count[i]){                 flag=count[i];                 temp=i;            }        switch(temp){        case 0:printf("Rose.\n");break;        case 1:printf("Letter.\n");break;        case 2:printf("Massage.\n");break;        case 3:printf("Wait.\n");break;        }    }    return 0;}

Problem H:

过山车

Time Limit:1000MS  Memory Limit:32768K
Total Submit:31 Accepted:4

Description

RPG girls今天和大家一起去游乐场玩,终于可以坐上梦寐以求的过山车了。可是,过山车的每一排只有两个座位,而且还有条不成文的规矩,就是每个女生必须找个个男生做partner和她同坐。但是,每个女孩都有各自的想法,举个例子把,Rabbit只愿意和XHD或PQK做partner,Grass只愿意和linle或LL做partner,PrincessSnow愿意和水域浪子或伪酷儿做partner。考虑到经费问题,boss刘决定只让找到partner的人去坐过山车,其他的人,嘿嘿,就站在下面看着吧。聪明的Acmer,你可以帮忙算算最多有多少对组合可以坐上过山车吗?

Input

输入数据的第一行是三个整数K , M , N,分别表示可能的组合数目,女生的人数,男生的人数。0<k<=1000
1<=N 和M<=500.接下来的K行,每行有两个数,分别表示女生Ai愿意和男生Bj做partner。最后一个0结束输入。

Output

对于每组数据,输出一个整数,表示可以坐上过山车的最多组合数。

Sample Input

6 3 31 11 21 32 12 33 10

Sample Output

3

Source

RPG专场练习赛

源代码:
  • #include<stdio.h>#include<string.h>int MAXN=510;int uN,vN;int g[510][510];int linker[510];int used[510];int dfs(int u){    int v;    for(v=1;v<=vN;v++)        if(g[u][v]&&!used[v])        {            used[v]=1;            if(linker[v]==-1||dfs(linker[v]))            {                linker[v]=u;                return 1;            }        }    return 0;}int hungary(){    int res=0;    int u;    memset(linker,-1,sizeof(linker));    for(u=1;u<=uN;u++)    {        memset(used,0,sizeof(used));        if(dfs(u))  res++;    }    return res;}int main(){    int k;    int u,v;    while(scanf("%d",&k),k)    {        scanf("%d%d",&uN,&vN);        memset(g,0,sizeof(g));        while(k--)        {            scanf("%d%d",&u,&v);            g[u][v]=1;        }        printf("%d\n",hungary());    }    return 0;}
以上源代码全部AC通过,这次比赛使用的是校内OJ系统,八道题做对了七道,校内排名第一。
好好准备,准备参加明年省里的比赛,加油!
另附上没做出来的那一题:
Problem D:

抗旱救灾之学校的苦恼

Time Limit:1000MS  Memory Limit:32768K
Total Submit:17 Accepted:0

Description

由于灾情越来越严重,学校师生的用水困难已成为现在最急需解决的问题,要给各学校提供用水,就必须先知道各学校是否与水库有道路相连。
请你编写一个程序,读入水库与各个学校以及所有道路的信息,计算有多少学校没有路与水库相通。

Input

输入有多组数据,每组数据第一行包括两个正整数n,m(0<n<1000,0<m<=(n*(n+1)

Output

对于每组输入数据,如果所有的学校均与水库相通,则请在一行内输出0;
如果有学校不通水库,则输出占两行,第一行是一个整数k(表示与水库无路连接的学校个数),第二行有k个正整数,分别表示无路与水库相连的学校的编号,按升序输出,每两个数之间用一个空格分开。

Sample Input

4 40 10 21 22 3

Sample Output

14

Source

ACM程序设计期末考试(晚上班)


请各路大神帮忙,帮老夫答疑解惑!
以上内容仅供参考,未经允许,不得复制
0 0
原创粉丝点击