[2020-3-6]BNUZ套题比赛div3解题报告

[2020-3-6]BNUZ套题比赛div3解题报告

2020/3/8
非常荣幸,本周蝉联了训练赛的第一名×2。不过,两个小时只憋出来两题,有点寒酸。(排名如下图)
NO.1
话不多说,上题

第一题 Pizza, Pizza, Pizza!!!
Katie, Kuro and Shiro are best friends. They have known each other since kindergarten. That’s why they often share everything with each other and work together on some very hard problems.

Today is Shiro’s birthday. She really loves pizza so she wants to invite her friends to the pizza restaurant near her house to celebrate her birthday, including her best friends Katie and Kuro.

She has ordered a very big round pizza, in order to serve her many friends. Exactly n of Shiro’s friends are here. That’s why she has to divide the pizza into n+1 slices (Shiro also needs to eat). She wants the slices to be exactly the same size and shape. If not, some of her friends will get mad and go home early, and the party will be over.

Shiro is now hungry. She wants to cut the pizza with minimum of straight cuts. A cut is a straight segment, it might have ends inside or outside the pizza. But she is too lazy to pick up the calculator.

As usual, she will ask Katie and Kuro for help. But they haven’t come yet. Could you help Shiro with this problem?

Input
A single line contains one non-negative integer n (0≤n≤1018) — the number of Shiro’s friends. The circular pizza has to be sliced into n+1 pieces.

Output
A single integer — the number of straight cuts Shiro needs.

Examples
在这里插入图片描述
Note
To cut the round pizza into quarters one has to make two cuts through the center with angle 90∘ between them.
To cut the round pizza into five equal parts one has to make five cuts.

以下是我的程序

#include<stdio.h>
#include<stdlib.h>
int main()
{
   long long int n;
    scanf("%lld",&n);
    if((n+1)%2==0||n==0)
    {
        printf("%lld\n",(n+1)/2);
    }
    else
    {
        printf("%lld\n",n+1);
    }
    return 0;
}

没有错,这是一道签到题。但为什么会错两次呢,第一次是因为没看数据范围用了int,第二次是因为没有考虑n=0的情况,太粗心了,白给40min的时长。(要不是做出最后一题就莫得了)这道题呢是奇数个人的话就要多加一个自己然后/2,如果是偶数个人的话加自己就之能嗯切那么多刀,然后要注意到只有自己一个人的情况,没啥可说的。

第二题 这道题是贪心,然后我没写出来,最主要是我忘了。师兄讲的时候,没听得太懂,最主要是卡在了自己的想法里面,而且自己的想法也没啥想法。插个眼,以后自学或者学到贪心再回来看这题。

第三题 这道题呢是dfs 再见 插个眼

第四题 A Compatible Pair
Nian is a monster which lives deep in the oceans. Once a year, it shows up on the land, devouring livestock and even people. In order to keep the monster away, people fill their villages with red colour, light, and cracking noise, all of which frighten the monster out of coming.

Little Tommy has n lanterns and Big Banban has m lanterns. Tommy’s lanterns have brightness a1, a2, …, an, and Banban’s have brightness b1, b2, …, bm respectively.

Tommy intends to hide one of his lanterns, then Banban picks one of Tommy’s non-hidden lanterns and one of his own lanterns to form a pair. The pair’s brightness will be the product of the brightness of two lanterns.

Tommy wants to make the product as small as possible, while Banban tries to make it as large as possible.

You are asked to find the brightness of the chosen pair if both of them choose optimally.

Input
The first line contains two space-separated integers n and m (2 ≤ n, m ≤ 50).

The second line contains n space-separated integers a1, a2, …, an.

The third line contains m space-separated integers b1, b2, …, bm.

All the integers range from  - 109 to 109.

Output
Print a single integer — the brightness of the chosen pair.

Examples
在这里插入图片描述
Note
In the first example, Tommy will hide 20 and Banban will choose 18 from Tommy and 14 from himself.
In the second example, Tommy will hide 3 and Banban will choose 2 from Tommy and 1 from himself.

以下是我的程序

#include<stdio.h>
int main()
{
	long long n,m,ii,max,a[110],b[110];
	while(~scanf("%lld %lld",&n,&m))
	{
		for (long long i=1;i<=n;i++) scanf("%lld",&a[i]);
		for (long long i=1;i<=m;i++) scanf("%lld",&b[i]);
		max=-9e18;
		for (long long i=1;i<=n;i++)
		{
			for (long long j=1;j<=m;j++)
			{
				if (max<a[i]*b[j])
				{
					ii=i;
					max=a[i]*b[j];
				}
			}
		}
		max=-9e18;
		for(long long i=1;i<=n;i++)
        {
            for(long long j=1;j<=m;j++)
            {
                if (i==ii) continue;
                if (max<a[i]*b[j]) max=a[i]*b[j];
            }
        }
        printf("%lld\n",max);
	}
	return 0;
}

这道题呢,训练赛的时候没写出来,我暴力过的,要注意的问题是long long int,然后把所有的情况存到一个数组里面,然后找第二大的输出来。很简单,但是为什么会错呢,因为我一直把一个数组名输错了,然后还能过6个数据。

第五题 A Prosperous Lot
Apart from Nian, there is a daemon named Sui, which terrifies children and causes them to become sick. Parents give their children money wrapped in red packets and put them under the pillow, so that when Sui tries to approach them, it will be driven away by the fairies inside.

Big Banban is hesitating over the amount of money to give out. He considers loops to be lucky since it symbolizes unity and harmony.

He would like to find a positive integer n not greater than 1018, such that there are exactly k loops in the decimal representation of n, or determine that such n does not exist.

A loop is a planar area enclosed by lines in the digits’ decimal representation written in Arabic numerals. For example, there is one loop in digit 4, two loops in 8 and no loops in 5. Refer to the figure below for all exact forms.

Input
The first and only line contains an integer k (1 ≤ k ≤ 106) — the desired number of loops.

Output
Output an integer — if no such n exists, output -1; otherwise output any such n. In the latter case, your output should be a positive decimal integer not exceeding 1018.

Examples
在这里插入图片描述
以下是我的程序

#include<stdio.h>
int main()
{
	int n,a,b;
	while(~scanf("%d",&n))
	{
		a=n/2;
		b=n%2;
		if (n<=36)
		{
			if (n==0) printf("1");
			else
			{
				for (int i=1;i<=a;i++) printf("8");
				for (int i=1;i<=b;i++) printf("9");
			}
		}
		else printf("-1");
		printf("\n");
	}
	return 0;
}

这道题呢,是我做过这么多题以来最神奇的,他有很多解。0 4 6 9是一个圈,8是两个圈。题目给你一个圈数,要你输出对应的数有那么多个圈。要注意第一个不能为0,还有就是36个圈会超出范围,要控制一下输出-1。

以上就是我的解题报告,题目能补就补,补不了就插眼以后做。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值