比赛链接

文章目录

  • A题 A Simple Problem about election
    • 题目描述
    • 题解:
    • 代码:
  • D题 Deploy the medical team
    • 题意:
    • 题解:
    • 代码:
  • F题 Figure out the sequence
    • 题意:
    • 题解:
    • 代码

A题 A Simple Problem about election

链接:

题目描述

n名候选人,每个人必须提名其中m个人,(也可以提名自己),候选人将按照获得的提名降序排列,如果数量相同则按照名字字典序递增排列。
每个人也是按照名字依次提名m人,
叫ZZZZSGW的这个人感觉自己太倒霉了,(名字这么多z,每次提名),他最后提名,问还能不能让自己获得最高地位?

样例:
输入

2
5 3
5 1 2 6 7
5 3
5 1 2 5 7

输出

3
2

题解:

自己肯定还是要给的,然后剩下的m-1个票就要尽可能与自己票数相差大的人(也就是不对自己的排名造成影响),有两种情况,一个是比自己票多的,还有个是被投一票也赶不上自己的
但是如果票过多,就只能被迫给剩下的人投票
贪心即可
详细见代码

代码:

#include<bits/stdc++.h>
#define forr(n) for(int i=1;i<=n;i++)
using namespace std;
const int maxn=1e5+7;
int a[maxn];
int main(){int T,ans=0;;cin>>T;while(T--){int n,m;scanf("%d%d",&n,&m);forr(n)cin>>a[i];int w=++a[1];//先给自己投票 int q=m;--q;//投完自己,投票次数少一个 if(q==0);else {for(int i=2;i<=n;++i){if(a[i]>=w)//如果票比他多 {++a[i];--q;}else if(a[i]+1<w)//如果这个人投一票也赶不上 {++a[i];--q;}if(!q)//如果都投完退出 {break;}}}for(n){if(a[i]>=a[1])ans++;}//全部投完票后看看自己排第几名 cout<<ans+q<<endl;//如果还有余票 }return 0;
}

D题 Deploy the medical team

链接:

题目描述

The outbreak of the COVID-19 has infected more than 50,000 people in
Wuhan and nearly 70,000 people in Hubei province, which brings on
great pressure on the local hospital and medical workers. To help the
people in Hubei defeating the virus and returning to normal life as
soon as possible, many other province deployed their medical teams to
Hubei and offered lots of help.

Now it’s the time for a hospital in Bitland to choose who will be sent
to join this great mission. There are nn medical workers in the
hospital ready to deploy and you can send arbitrary numbers of persons
to the team. Also, a medical team need a captain in charge of all the
work, so once we confirm the people in the team, we need to set one of
them as captain too. However, being a captain needs a lot experience,
so there are only mm people capable with the responsibility of a
captain. Therefore, A team cannot be made up of people without someone
that can be the captain.

And here’s the question: How many ways are there to pick up a medical
team with a captain? Notice that two teams are consider different as
long as they have different participants or have different captain.

Also, due to the large memory of Bitland, the number of workers in
hospital can be as large as 109 ! And that means your answer can be
very large, so please output the result of the answer modulo 109+7

输入描述:

The input consists of multiple test cases. The first line of the input
contains an integer T — the number of the test cases.

For each test cases, there will be two integers nn,mm separated by
space in one line, which means the number of workers in hospital and
the numbers of people who can be the captain. Here 0≤m≤n≤109 .

输出描述:

For each test case, output a single integer ansans in a line, denoting
the answer modulo 109+7

示例1
输入

3
3 3
5 4
2 1

输出

12
64
2

题意:

一共n个人,m个人可以当队长,每个队只能有一个队长,也必须有一个队长,问组队方法?
(最讨厌英语题了)

题解:

组合数问题
先从m人中选一个队长,剩下n-1个人任选即可
C0n-1+C1n-1+C2n-1…+Cn-1n-1=2n-1
sum=m*2n-1

代码:

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
ll qpow(ll a, ll b)
{ll ans = 1;while(b) {if(b & 1) ans = ans * a % mod;a = a * a % mod;b >>= 1;}return ans;
}
int T;
ll n, m;
int main() {cin >> T;while(T--) {cin >> n >> m;printf("%lld\n",m * qpow(2, n - 1) % mod );}return 0;
}

F题 Figure out the sequence

题意:

两个字符串,一次叠加,问你n轮后,每个字母出现个数

样例:
链接:https://ac.nowcoder.com/acm/contest/5523/F
来源:牛客网

输入

Abc
def
4

输出

A: 1
b: 1
c: 1
d: 2
e: 2
f: 2

根据样例输入我们可以都到每轮叠加后的串

n=4时就是 defabcdef
分别统计每个字母的个数

题解:

dp
我们可以看出要求第n轮,就是第n-1轮加n-2轮
因为问的是个数,所以不用管顺序递推就可以
f[i][j]表示第i个字符串中字母j出现的次数(此处j为int型对应的是char型的字符)
得到递推式:f [ i ] [ j ] = f[ i - 1 ] [ j ]+ f [ i -2 ] [ j ]
我们一开始将读入的s1和s2进行预处理
也就是先给f[1][j]与f[2][j]赋值
具体可以看代码:

代码

#include<bits/stdc++.h>
#define forr(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int maxn=1e5+7;
ll f[maxn][1000];
inline ll read()
{ll s=0,w=1;char ch=getchar();while(ch<48||ch>57){if(ch=='-')w=-1;ch=getchar();}while(ch>=48&&ch<=57)s=(s<<1)+(s<<3)+(ch^48),ch=getchar();return s*w;
}
int main()
{string s1,s2;int n;cin>>s1>>s2;n=read();forr(i,s1.size()){int w=(int)s1[i];f[1][w]++;
//      printf("%c %lld\n",w,f[1][w]);}forr(i,s2.size()){int w=(int)s2[i];f[2][w]++;}for(int i=3;i<=n;i++){forr(j,300){f[i][j]=f[i-1][j]+f[i-2][j];}}forr(j,300){if(f[n][j])printf("%c: %lld\n",j,f[n][j]);}return 0;}
//“defabcdef”

“Shopee杯” e起来编程暨武汉大学2020年大学生程序设计大赛决赛(重现赛)相关推荐

  1. 【题解】吉首大学第九届"新星杯"大学生程序设计大赛(重现赛)

    文章目录 B - Y 老师的井字窗(签到) C - 始战(思维) D - 秒速五厘米(二分) E - 冬天怎么能够没有辣条(签到) H - 小李堆积木(模拟) I - Y 老师的乐高小镇(数学) J ...

  2. 吉首大学第九届"新星杯"大学生程序设计大赛(重现赛)

    A 被诅咒的WWT 题目描述 WWT因为过于可爱被一个邪恶的巫师施了魔咒,将WWT变成了一维的,并将他放到了一根坐标轴的坐标原点上,巫师的魔咒极其强大,WWT需要在坐标轴上移动十二步,且每一步只能移动 ...

  3. 吉首大学第九届"新星杯"大学生程序设计大赛(重现赛)(回顾补题)

    这次比赛6/13,可惜可惜,差一题就达到既定目标,自身思想出了问题,没

  4. 2020安徽省大学生程序设计大赛题解——E 收集圣物

    2020安徽省大学生程序设计大赛题解--E 收集圣物 E 收集圣物 在一个策略游戏中,僧侣单位可以收集圣物,放入修道院中,以生产黄金.因此,圣物对赢得游戏的胜利很重要. 某个僧侣正处于一个长为n 宽为 ...

  5. 2020安徽省大学生程序设计大赛题解——A数字排列

    2020安徽省大学生程序设计大赛题解--A数字排列 A 数字排列 给出两个整数A 和 B,可以重新排列A 得到新的数字C(不能有前导0).求在小于等于B的情况下,C的最大值是多少.如果不存在输出-1. ...

  6. 2020安徽省大学生程序设计大赛题解——K 农夫打狼

    2020安徽省大学生程序设计大赛题解--K 农夫打狼 K 农夫打狼 题解 标签 排序,动态规划 分析 图K−1本题的一个样例,彩色十字为起点和终点图K-1 \ \ \ \ 本题的一个样例,彩色十字为起 ...

  7. 2020安徽省大学生程序设计大赛题解——F 跳蛙出行

    2020安徽省大学生程序设计大赛题解--F 跳蛙出行 F 跳蛙出行 池塘里有n片荷叶排成一行,有一只青蛙在上面跳跃.但是,这只青蛙是只不同寻常的青蛙,它每跳一次,只能从一片荷叶跳到相邻的荷叶上,并且, ...

  8. 【Java/补题/牛客/ACM赛制】2021年ICPC国际大学生程序设计竞赛暨陕西省第九届大学生程序设计竞赛(正式赛)

    文章目录 题目链接 知识一览 题目列表 快输 C - GCD(数论分块) 题目链接 2021年ICPC国际大学生程序设计竞赛暨陕西省第九届大学生程序设计竞赛(正式赛) 知识一览 01-数论分块 题目列 ...

  9. 2020安徽省大学生程序设计大赛题解——J 飞奔的战士

    2020安徽省大学生程序设计大赛题解--J 飞奔的战士 J 飞奔的战士 题目 众所周知, T e u t o n i c K n i g h t Teutonic Knight TeutonicKni ...

最新文章

  1. CENTOS安装ElasticSearch
  2. 【TCP/IP详解 卷一:协议】第十八章 TCP连接 的建立与终止 (2)其余内容
  3. ENSP配置 实例七 DHCP配置
  4. Robots.txt 协议——百度之星
  5. [渝粤教育] 武汉理工大学 复变函数与积分变换 参考 资料
  6. 华表Cell应用 - 使用XML自动读入数据 | #报表 #华表Cell
  7. 2019 中科院 信工所二室 夏令营 笔试面试经验
  8. 第一章 DirectX 计算机图形学(上)
  9. Burg法求解AR(p)模型参数及MATLAB实现
  10. python樱花_Python实现浪漫的樱花与烟花雨
  11. 网页性能测试工具大全
  12. Linux宝塔面板命令大全,快速学会
  13. 继承(下)----虚继承
  14. 用Javascript开发《三国志曹操传》-开源讲座(二)-人物行走的实现
  15. 视频号6种技巧主动引导用户评论
  16. 数据挖掘第四课(贝叶斯网络)
  17. Java 垃圾回收最全讲解(GC过程、可达性分析、方法,7大回收器)
  18. 【Unity Assetstore】上传插件
  19. 从放大器开始谈模拟电子
  20. 【精选】JAVA算法题(二十)

热门文章

  1. 每日一笑 | 今天是植树节,我想在你心里种点逼树
  2. 需求分析 应该先写业务还是功能_一个套路,拆解常见数据分析需求
  3. sql 百分数_SQL经典50题笔记
  4. php maximum,解决PHP程序运行时:Fatal error: Maximum execution time of 30 seconds exceeded in的错误提示...
  5. websocket文档_WebSocket推送 原理扫盲到上手实践
  6. 帆软获取上月的第一天与最后一天_《原神》岩港打工第一天怎么玩 岩港打工第一天玩法攻略...
  7. azure linux 多磁盘 lvm,EVE-NG扩展磁盘空间(扩展LVM卷)
  8. com.mysql.cj.exceptions.InvalidConnectionAttributeException
  9. leetcode 515. 在每个树行中找最大值(层序遍历06)
  10. 7-6 区间覆盖 (10 分)(思路+详解)Come 宝!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!