当前位置:网站首页>*6-3 save small experts
*6-3 save small experts
2022-07-25 09:38:00 【Ye Xiaobai】
Thrift expert
Title Description

Source code
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 100000;
int a[N + 1];
int b[N + 1];
bool cmp(int a, int b)
{
return a > b;
}
int main()
{
int n, m,t=0,d,i,j;
cin >> n >> m;
int count = 0;
int x;
for ( i = 0; i < n; i++)
{
cin >> a[i];
}
while (1)
{
for (j = 2; j <= a[n - 1]; j++)
{
t = 0;
for (i = 0; i < n; i++)
{
t += a[i] / j;
if (t == m)
{
b[i] = j;
break;
}
}
}
sort(b, b + N + 1, cmp);
cout << b[0] << endl;
break;
}
return 0;
}
About this problem
This is used here. sort To help us sort
If the number of pieces meets the requirements We'll save it b In the array Reuse sort Sort in descending order Find the longest length
( This question given by the teacher There is no place to test the code The two cases given in the title can be passed )
边栏推荐
猜你喜欢

最短路问题 Bellman-Ford(单源最短路径)(图解)

A brief introduction to the interest of convolutional neural networks

Class (2) and protocol

main函数的一些操作
![[GKCTF 2021]easynode](/img/f0/1daf6f83fea66fdefd55608cbddac6.png)
[GKCTF 2021]easynode
![[HCTF 2018]admin](/img/d7/f0155c72d3fbddf0a8c1796a179a0f.png)
[HCTF 2018]admin

OC--初识

~4.2 ccf 2021-12-1 序列查询

How to deploy the jar package to the server? Note: whether the startup command has nohup or not has a lot to do with it
![[GPLT] 2022 大众情人(floyd)](/img/30/c96306ca0a93f22598cec80edabd6b.png)
[GPLT] 2022 大众情人(floyd)
随机推荐
Prim minimum spanning tree (diagram)
OC -- object replication
~1 ccf 2022-06-2 寻宝!大冒险!
[GYCTF2020]Node Game
main函数的一些操作
【代码源】每日一题 树
Detailed explanation of the use of nanny scanner class
The shortest path problem Bellman Ford (single source shortest path) (illustration)
Week summary
CoreData存储待办事项
~5 ccf 2021-12-2 序列查询新解
梦想启航(第一篇博客)
~3 ccf 2022-03-2 出行计划
Kotlin 实现文件下载
Kotlin协程:协程的基础与使用
Redis set 结构命令
Basic network knowledge
一张图讲解 SQL Join 左连 又连
Redis database foundation
[gplt] 2022 popular lover (Floyd)