HRBUACM 2018级ACM第一次选拔赛正式赛

写在前边

首先我在看到这套题的时候感觉很简单,但是实际上做起来坑的地方很多(谁让我是个菜鸡)。反正多了也不说了,下边附上这些题和AC代码。

B和D是本次比赛的签到题。CFGJ是中等难度的题。AEHI难度较高的题目。

D - Welcome

Description
在这个硕果累累的秋天我校迎来了2018级的新同学。为了表示热烈的欢迎,打算在2号教学楼大厅的LED显示屏上显示“Welcome to HRBU College of Information Engineering“ 的字样。辅导员将这个任务派给了小明,可小明是真的不会,眼看新生即将到来你能帮助小明完成这个任务吗?

Input

Output
请在屏幕中显示“Welcome to HRBU College of Information Engineering”(无双引号)

AC代码:

#include<stdio.h>
int main()
{
    printf ("Welcome to HRBU College of Information Engineering\n");
}

B - 悲催的小明

Description
由于入学初辅导员派给自己的任务没有很好地完成,小明计划将C语言从头进行复习,他打算用90天时间复习完。假设今天(2018-11-03)是第一天,请问复习的最后一天是什么时候?

Input

Output
按照格式要求输出最后一天的日期,“XXXX年XX月XX日”(注意:包含前导0,无双引号)

AC代码:

#include<stdio.h>
int main()
{
    printf ("2019年01月31日\n");
}

C - 时制转换

Description
编写一个程序,要求用户输入24小时制的时间,然后显示12小时制的时间

Input
输入在一行中给出带有中间的“:”符号(半角的冒号)的24小时制的时间,如12:34表示12点34分。当小时或分钟数小于10时,均没有前导的零,如5:6表示5点零6分。

提示:在scanf的格式字符串中加入“:”,让scanf来处理这个冒号。

Output
在一行中输出这个时间对应的12小时制的时间,数字部分格式与输入的相同,然后跟上空格,再跟上表示上午的字符串“AM”或表示下午的字符串“PM”。如“5:6 PM”表示下午5点零6分。注意,在英文的习惯中,中午12点被认为是下午,所以24小时制的12:00就是12小时制的12:0 PM;而0点被认为是第二天的时间,所以是0:0 AM。

Sample Input
21:11

Sample Output
9:11 PM

AC代码:

#include<stdio.h>
int main()
{
    int a, b;
    scanf ("%d:%d", &a, &b);
    if (a == 12)
        printf ("12:%d PM\n", b);
    else if (a > 12 && a < 24)
        printf ("%d:%d PM\n", a - 12, b);
    else if(a == 24)
        printf ("0:%d AM\n", b);
    else
        printf ("%d:%d AM\n", a, b);
}

F - 三天打鱼两天晒网

Description
中国有句俗语叫“三天打鱼两天晒网”。假设某人从某天起,开始“三天打鱼两天晒网”,问这个人在以后的第N天中是“打鱼”还是“晒网”?

Input
输入在一行中给出1个不超过1000的正整数N

Output
在一行中输出此人在第N天中是“Fishing”(即“打鱼”)还是“Drying”(即“晒网”),并且输出“in day N”。

Sample Input
103

Sample Output
Fishing in day 103

Sample Input 2
34

Sample Output 2
Drying in day 34

AC代码:

#include<stdio.h>
int main()
{
    int n;
    scanf ("%d", &n);
    if (n % 5 == 1 || n % 5 == 2 || n % 5 == 3)
        printf ("Fishing in day %d\n", n);
    else if (n % 5 == 4 || n % 5 == 0)
        printf ("Drying in day %d\n", n);
}

G - 最小的数

Description
小明想知道在一组无序排列的数中最小的数是谁,请你帮助他完成任务

Input
输入正整数n,代表这一组中有多少个数(n不超过10000)

接下来一行输入n个整数

Output
输出其中最小的数并换行

AC代码:

#include<stdio.h>
int main()
{
    int n, a, min = 10001;
    scanf ("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf ("%d", &a);
        if (a < min)
            min = a;
    }
    printf ("%d\n", min);
}

J - Found

Description
要求从输入的N个整数中查找给定的X。如果找到,输出X的位置(从0开始数);如果没有找到,输出“Not Found”。

Input
输入在第1行中给出2个正整数N(<=20)和X,第2行给出N个整数。数字均不超过长整型,其间以空格分隔。

Output
在一行中输出X的位置,或者“Not Found”。

Sample Input
5 7
3 5 7 1 9

Sample Output
2

Sample Input 2
5 7
3 5 8 1 9

Sample Output 2
Not Found

AC代码:

#include<stdio.h>
int main()
{
    int n, x, a[21], flag = 0;
    scanf ("%d%d", &n, &x);
    for (int i = 0; i < n; i++)
        scanf ("%d", &a[i]);
    for (int i = 0; i < n; i++)
    {
        if (a[i] == x)
        {
            printf ("%d\n", i);
            flag = 1;
            break;
        }
    }
    if (flag == 0)
        printf ("Not Found\n");
}

A - 相交?相离?相切

Description
已知两个圆的圆心坐标O1,O2以及各自的半径r1,r2 小明数学很差请你告诉他这两个圆的状态

Input
第一行给出四个整数x1,y1,x2,y2,分别表示两个圆的圆心横坐标以及纵坐标(-1000<=x1,x2,y1,y2<=1000)

第二行给出两个正整数,分别表示两个圆的半径r1r2(1<=r1, r2<=1000)

Output
给出两个圆的状态(intersect【相交】,tangent【相切】,separation【相离】)若为同一个圆请输出“Sample circle”(输出无双引号)

Sample Input
1 1 2 2
1 1

Sample Output
intersect

Sample Input 2
1 1 1 1
1 1

Sample Output 2
Sample circle

Sample Input 3
1 1 3 1
1 1

Sample Output 3
tangent

AC代码:

#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int main()
{
    int x1, x2, y1, y2, r1, r2;
    scanf ("%d%d%d%d%d%d", &x1, &y1, &x2, &y2, &r1, &r2);
    if (x1 == x2 && y1 == y2 && r1 == r2)
        printf ("Sample circle\n");
    else
    {
        double s2 = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
        double s1 = r1 + r2;
        if (s2 == s1 || s2 == abs(r1 - r2)) printf ("tangent\n");
        else if (s1 > s2 && s2 > abs(r1 - r2)) printf ("intersect\n");
        else printf ("separation\n");
    }
}

E - 后缀名

Description
在课堂上,老师布置了一个任务,给出一个文件名,请根据文件的后缀名来确定程序是用什么语言编写的?

(规则如下:.java是java写的,.cpp是c++写的,*.c是c写的,如果不是这三种语言则输出none)。

比如a.cpp 说明使用c++编写的,b.c 说明使用c编写的,c.java 说明使用java编写的

Input
输入一个字符串,字符串长度不超过20。

字符串格式为s1.s2,字符串s1和s2均由小写字母构成,保证不为空串。

并且字符串只含字母和点号,不包含其他空白字符。

Output
根据文件名的后缀来确定是什么语言编写,如果是C语言编写的请输出“c”(无双引号);如果是C++语言编写的请输出“c++”(无双引号);如果是Java语言编写的请输出“java”(无双引号);如果不存在上述三种语言的后缀,则输出none。

Sample Input
a.cpp

Sample Output
c++

AC代码:

#include <iostream>
#include <string>
using namespace std;
int main()
{
    int flag = 1;
    string a;
    while(cin >> a)
    {
        for (int i = 0; i < a.length(); i++)
        {
            if (a[i] == '.')
            {
                if (a[a.length() - 1] == 'c') cout << "c" << endl;
                else if(a[a.length() - 1] == 'p' && a[a.length() - 2] == 'p' && a[a.length() - 3] == 'c') cout << "c++" << endl;
                else if(a[a.length() - 1] == 'a' && a[a.length() - 2] == 'v' && a[a.length() - 3] == 'a' && a[a.length() - 4] == 'j') cout << "java" << endl;
                else cout << "none" << endl;
                flag = 1;
                break;
            }
            else flag = 0;
        }
        if (flag == 0) cout << "none" << endl;
    }
}

H - BCD数

Description
BCD数是用一个字节来表达两位十进制的数,每四个比特表示一位。所以如果一个BCD数的十六进制是0x12,它表达的就是十进制的12。但是小明没学过BCD,把所有的BCD数都当作二进制数转换成十进制输出了。于是BCD的0x12被输出成了十进制的18了!

现在,你的程序要读入这个错误的十进制数,然后输出正确的十进制数。提示:你可以把18转换回0x12,然后再转换回12。

Input
输入在一行中给出一个[0, 153]范围内的正整数,保证能转换回有效的BCD数,也就是说这个整数转换成十六进制时不会出现A-F的数字。

Output
输出对应的十进制数

Sample Input
18

Sample Output
12

AC代码:

#include<stdio.h>
int main()
{
    int n;
    scanf ("%d", &n);
    printf ("%d\n", n % 16 + n / 16 * 10);
}

I - 猜数字

Description
猜数字游戏是令系统随机产生一个100以内的正整数,用户输入一个数对其进行猜测,需要你编写程序自动对其与随机产生的被猜数进行比较,并提示大了(“Too big”),还是小了(“Too small”),相等表示猜到了。如果猜到,则结束程序。程序还要求统计猜的次数,如果1次猜出该数,提示“Bingo!”;如果3次以内猜到该数,则提示“Lucky You!”;如果超过3次但是在N(>3)次以内(包括第N次)猜到该数,则提示“Good Guess!”;如果超过N次都没有猜到,则提示“Game Over”,并结束程序。如果在到达N次之前,用户输入了一个负数,也输出“Game Over”,并结束程序。

Input
输入第一行中给出2个不超过100的正整数,分别是系统产生的随机数、以及猜测的最大次数N。随后每行给出一个用户的输入,直到出现负数为止。

Output
在一行中输出每次猜测相应的结果,直到输出猜对的结果或“Game Over”则结束。

Sample Input
58 4
70
50
56
58
60
-2

Sample Output
Too big
Too small
Too small
Good Guess!

AC代码:

#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int main()
{
    int a, n, x, flag = 0;
    scanf ("%d%d", &a, &n);
    for (int t = 1; t < 100; t++) {
        scanf ("%d", &x);
        if(x < 0 && t <= n) {
            printf ("Game Over\n");
            break;
        }
        else if (x >= 0) {
            if (x > a && t <= n) printf ("Too big\n");
            else if (x < a && t <= n) printf ("Too small\n");
            else if (x == a && t <= n) {
                flag = 1;
                if (t == 1) {
                    printf ("Bingo!\n");
                    break;
                }
                else if (t == 2) {
                    printf ("Lucky You!\n");
                    break;
                }
                else if (t >= 3) {
                    printf ("Good Guess!\n");
                    break;
                }
            }
            else if (flag == 0 && t > n) {
                printf("Game Over\n");
                break;
            }
        }
        else if (t > n) {
            if (flag == 0) {
                printf ("Game Over\n");
                break;
            }
            else break;
        }
    }
    return 0;
}

篇尾

此次比赛的所有题目均是原创,如果有转载等同学请标明出处。

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Beginning Amazon Web Services with Node.js teaches any novice Node.js developer to configure, deploy, and maintain scalable small to large scale Node.js applications in Amazon Web Services. Hosting a Node.js application in a production environment usually means turning to PaaS hosting, but this approach brings problems. Deploying Node.js directly to AWS solves the problems you encounter in these situations, enabling you to cut out the middle man. You will begin with a basic RESTful web service in Node.js, using the popular Express.js framework, pre-built and ready to run in your local environment. You will be introduced to the most powerful tools in AWS, and learn how to configure your project to take advantage of them. You will be guided through the steps of getting the various key components to work together on AWS. Through code samples using the AWS JavaScript SDK and tutorials in the AWS console, you will gain the knowledge to incorporate secure user authentication, server auto-scaling, a load balancer, CDN, customized caching behavior, and outage monitoring. Node.js is single-threaded, and designed to run high input / high output applications, making it ideal for the cloud environment. If your main task is handling a high volume of requests over HTTP / the web, it will scale very well in proportion to the computing power you allocate to it. Amazon Web Services offers a broad set of services that help organizations move faster, lower costs, and scale applications. Trusted by the largest enterprises and start-ups alike, AWS powers a wide variety of workloads across a broad spectrum. If leveraged properly, you can build a Node.js app on AWS which can automatically power itself up to handle a massive volume of traffic, and then scale back down to a lighter configuration when user demand has dropped. Amazon Web Services offers a broad set of services that help organizations move faster, lower costs, and scale applications. Get started with Node.js and AWS using this book today. What you’ll learn ● Using AWS Opsworks to architect and configure a secure web application built for hosting in the cloud. ● Integrating AWS Cloudwatch, SES, and other AWS services into your code. ● Using AWS Route 53 to configure your domain to use a load balancer, CDN, and other performance-enhancing services into your application. ● Deploying with AWS Opsworks and using AWS services to monitor, scale, and maintain your application. Who this book is for This book is intended for a beginner/novice Node.js developer who has traditionally relied on PaaS services such as Heroku or Parse to host their web applications. This book aims to empower the reader to work directly in AWS, in order to manage their own infrastructure. Hosting a Node.js application in a production environment usually means turning to PaaS hosting such as Heroku or AppFog, but this approach brings problems. Deploying Node.js directly to AWS solves the problems you encounter in these situations, enabling you to cut out the middle man. If leveraged properly, you can build a Node.js app on AWS which can automatically power itself up to handle a massive volume of traffic, and then scale back down to a lighter configuration when user demand has dropped. Table of Contents Chapter 1: Getting Started with Amazon Web Services Chapter 2: Working with AWS OpsWorks Chapter 3: OpsWorks Part II: Databases and Scaling Chapter 4: CloudFront and DNS Management Chapter 5: Simple Storage Service and Content Delivery Chapter 6: Simple Email Service Chapter 7: Monitoring the Application Chapter 8: Securing the Application

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值