2020第一届大湾区信息学竞赛U12组第二场初赛真题参考答案

一、选择题(每题4分,共40分)

1 答案:C

2 答案:B

3 答案:C

4 答案:A

5 答案:C

6 答案:D

7 答案:A

8 答案:B

9 答案:C

10 答案:D

二、填空题(每题8分,共40分)

1 答案:8

2 答案:5:9

3 答案:4

4 答案:37

5 答案:True

三、程序完善题(每空2分,共20分)

1

#include<iostream>
using namespace std;
int main()
{
    int n, i;
    cout << "请输入整数:";
    cin >> n;
    cout<<"n=";
    for(i=2; i<=n; i++)
    {
        //判断是否被整除
        while(n % i == 0)
        {
            cout << i;
            n /= i;
            if(n!=1) cout << '*';
        }
    }
    return 0;
}

2

#include<iostream>
using namespace std;
int a, b, n, h;

int main()
{
	cin >> a >> b >> n;
	int d = 1;		//初始化天数
	h = a;			//初始化青蛙爬了的高度
	while (h < n)   //小青蛙没有爬出井的时候
    {
		h -= b;		//晚上下滑b米
		d ++;		//天数增加
		h += a;		//白天向上爬a米
	}
	cout << d;
	return 0;
}

四、编程题(每题100分,共200分)

1

#include <iostream>
using namespace std;

double n, t;

int main()
{
    int cnt = 0;
    cin >> n;
    do
    {
        cnt++;
        if(cnt & 1) //通讯员从A往B
        {
            t = n / 68;
        }
        else    // 通讯员从B往A
        {
            t = n / 70;
        }
        n -= 18 * t;
    }while(n >= 0.5);

    cout << cnt;

    return 0;
}

2

//Author: Theo
#include <iostream>
using namespace std;

int mx = INT_MIN, mn = INT_MAX;

int main()
{
    int n, sum = 0;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        mx = max(x, mx);
        mn = min(mn, x);
        sum += x;
    }
    double ans = ((sum - mx - mn) * 1.0) / (n - 2.0);
    printf("%.2lf\n", ans);
    return 0;
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值