济南赛补题

M题

  • 题目

In China, there is a very famous problem about pancakes: You have a pan and you can fry two pancakes at the same time each time. For a pancake, its front and back sides need to be cooked, and it takes one hour for each side to be cooked.

So how long does it take at least to cook 3 pancakes? The answer is three hours:

In the first hour, fry the front of No.1 pancake and the front of No.2 pancake.

In the second hour, fry the back of No.2 pancake and the front of No.3 pancake.
In the third hour, fry the back of No.1 pancake and the back of No.3 pancake.
Now you have a pan and you can fry KK pancakes at the same time each time. How many hours does it takes at least to cook NN pancakes?
It’s noticed that you have to fry some side of the pancake until fully cooked every time, it means that you can’t fry some side of the pancake half-cooked and taking it out. So the answers are always integers.

  • 题意

一口锅可以同时煎制k个饼,每张饼两面都需要煎制,每一面需要煎1小时,问最快把n张饼全部煎好需要多少小时

  • 思路

共有n张饼就意味着如果一张一张煎制的话总时间是2n 但是现在可以同时煎制
如果2 ∗ n % k = 0 2
n%k=02∗n%k=0 就可以每次都放上去k张,这样答案就是2 ∗ n / k 2n/k2∗n/k
如果2 ∗ n % k ! = 0 2
n%k!=02∗n%k!=0 就可以像题目那样交叉着煎制,到最后把小于k的剩余饼全都放上去煎制好就成了,答案是2 ∗ n / k + 1 2*n/k+12∗n/k+1

  • 代码
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int n,k;
    cin>>n>>k;
    int now = 2 * n / k + (2 * n % k == 0?0:1);
    if(now < 2) now = 2;
    cout<<now;
}
 
/*
 
4 2 4
4 3 3
4 4 2
4 5 2
4 6 2
4 8 1
 
*/

G题

  • 题目

题目描述
MianKing has one integer XX, he wants to perform some operations to transform XX to YY (Y<X)(Y<X).
In each operation, MianKing can choose one integer 0\leq A<X0≤A<X and let X=XxorAX=X xor A.
it’s noticed that after an operation, the upper bound of AA will change because XX has changed.
Now you need to help MianKing to find a way to transform XX to YY by doing at most 55 operations.

输入描述:
The first line has two integers X,YX,Y.

1 < = Y < X < = 1 0 18 1<=Y<X<= 10^{18} 1<=Y<X<=1018
1 ≤ Y < X ≤ 1 0 18 1≤Y<X≤10^{18} 1Y<X1018
.

输出描述:
The first line has one integer d denotes the number of operations you did.
Then there are d integers A 1... d A_{1...d} A1...d
0 ≤ d ≤ 5 0≤d≤5 0d5.

  • 思路

    如果 X x o r Y < X X xor Y<X XxorY<X 那就直接异或 X^Y 否则先异或上Y,再异或上X。

  • 代码
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll X,Y;cin>>X>>Y;
    if((X^Y)<X)
    {
        printf("1\n");
        printf("%lld\n",X^Y);
    }
    else
    {
        printf("2\n");
        
        cout<<Y<<" "<<X<<endl;
    }
}

C题

  • 题意
    a 1 , a 2 , a 3 a_1,a_2,a_3 a1,a2,a3 堆数量分别为1,2,3 的石子,每次合并花费为 ( x   m o d   3 ) ∗ ( y   m o d   3 ) (x~mod ~3)*(y~mod~3) (x mod 3)(y mod 3), 问合成一堆最小花费是多少?
  • 思路
    这题太简单了,直接一发   A C   ~AC~  AC 。就是分类讨论就可了,直接看代码。
  • 代码
#include<iostream>

using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int res=0;
    if(a<b)
    {
        res+=(a*2);
        b-=a;
        int x=b/3;
        res+=x*6;
        if(b%3==2)
            res+=4;
        cout<<res<<endl;
    }
    else if(a==b)
    {
        cout<<2*a<<endl;
    }
    else
    {
        res+=2*b;
        a-=b;
        int x=a/3;
        res+=x*3;
        if(a%3==2)
            res+=1;
        cout<<res<<endl;
    }
}

D题

  • 题意
    n个同学,每个同学写论文的字数区间 [ l , r ] [l,r] [lr],与此同时他们的成绩是 n − k i n-k_i nki k i k_i ki 是指比他字数写的多的人的个数。这题给了一个初始 p l a n plan plan,就是每个人按自己的字数最大值去写,所以每个人都有一个初始成绩,但是,为了尽量的缩短需要写的论文的字数,并保证成绩不会低于初始成绩的条件下,求 ∑ i = 0 n w i \sum_{i=0}^n w_i i=0nwi 最小值。
  • 思路
    贪心。按照 R R R 为第一关键字、 L L L 为第二关键字排序。 R R R相同的直接去所有能满足条件的最小的就行。注意要始终更新每个区间能满足的最小值。
  • 代码
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int N=1e5+10;
struct node {
	ll l,r;
}X[N];

bool cmp(node a,node b)
{
	if(a.r==b.r)
		return a.l<b.l;
	return a.r<b.r;
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>X[i].l>>X[i].r;
	}
	sort(X+1,X+1+n,cmp);
	ll last=X[1].r;
	ll res=0;
	int k=1;
    ll m=X[1].l;
	for(int i=2;i<=n;i++)
	{
		if(X[i].r==last)
		{
			k++;
		}
		else
		{
            m=max(m,X[i-1].l);
			res+=(k*m);
			last=X[i].r;
			k=1;
		}
	}
	res+=(k*max(m,X[n].l));
	cout<<res<<endl;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
资源包主要包含以下内容: ASP项目源码:每个资源包中都包含完整的ASP项目源码,这些源码采用了经典的ASP技术开发,结构清晰、注释详细,帮助用户轻松理解整个项目的逻辑和实现方式。通过这些源码,用户可以学习到ASP的基本语法、服务器端脚本编写方法、数据库操作、用户权限管理等关键技术。 数据库设计文件:为了方便用户更好地理解系统的后台逻辑,每个项目中都附带了完整的数据库设计文件。这些文件通常包括数据库结构图、数据表设计文档,以及示例数据SQL脚本。用户可以通过这些文件快速搭建项目所需的数据库环境,并了解各个数据表之间的关系和作用。 详细的开发文档:每个资源包都附有详细的开发文档,文档内容包括项目背景介绍、功能模块说明、系统流程图、用户界面设计以及关键代码解析等。这些文档为用户提供了深入的学习材料,使得即便是从零开始的开发者也能逐步掌握项目开发的全过程。 项目演示与使用指南:为帮助用户更好地理解和使用这些ASP项目,每个资源包中都包含项目的演示文件和使用指南。演示文件通常以视频或图文形式展示项目的主要功能和操作流程,使用指南则详细说明了如何配置开发环境、部署项目以及常见问题的解决方法。 毕业设计参考:对于正在准备毕业设计的学生来说,这些资源包是绝佳的参考材料。每个项目不仅功能完善、结构清晰,还符合常见的毕业设计要求和标准。通过这些项目,学生可以学习到如何从零开始构建一个完整的Web系统,并积累丰富的项目经验。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

疯狂的码泰君

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值