2021中石油组队训练第八场记录(下)

简介: 题目描述Alice and Bob decide to share a chocolate bar, which is an n by m rectangular grid of chocolate cells. They decide that Alice should get a < n·m pieces and that Bob should get b = n·m − a pieces. To split the chocolate bar, they repeatedly take a single piece of chocolate and break it either

问题 C: Cocoa Coalition

时间限制: 1 Sec 内存限制: 128 MB


题目描述


Alice and Bob decide to share a chocolate bar, which is an n by m rectangular grid of chocolate cells. They decide that Alice should get a < n·m pieces and that Bob should get b = n·m − a pieces. To split the chocolate bar, they repeatedly take a single piece of chocolate and break it either horizontally or vertically, creating two smaller pieces of chocolate. See Figure C.1 for an

example.

What is the minimum number of splits that Alice and Bob need to perform in order to split the n-by-m chocolate bar into two piles consisting of a and b chocolate cells?

微信图片_20220531162949.png

Figure C.1: Illustration of a solution to Sample Input 2, showing the original 10-by-10 chocolate bar split three times into pieces of size 10-by-2, 10-by-5, 3-by-3 and 7-by-3. Giving Alice the 10-by-5 and 7-by-3 pieces, she gets a total of 50 + 21 = 71 chocolate cells.


输入


The input consists of a single line, containing the three integers n, m and a (1 ≤ n, m ≤ 106 ,1 ≤ a < n · m).


输出


Output the minimum number of splits needed to achieve the desired division of chocolate.


样例输入 Copy


3 10 9


样例输出 Copy


1


题目大意:


给出一个矩形的巧克力方块,每个小方块是1*1的,每次可以横着或者是竖着切一刀,问切出面积总共为 a 的一块最少需要操作几次


有一种情况是:

5 * 15 的方块,切出大小为31的一块,最少是两刀,不是三刀:

第一次切出45的一块来,然后右面剩下的事511的一块,然后正好还差 11小块,此时切一刀解决问题


Main_code:


  ll n, m, a; cin >> n >> m >> a;
    ll _a = a;
    if (2 * a > n * m) a = n * m - a;
    if (n > m) swap(n, m);
    if (a % n == 0 || a % m == 0) {
        cout << 1 << endl;
        return 0;
    }
    if (a >= 1 && a < m) {
        cout << 2 << endl;
        return 0;
    }
    for (ll i = 2; i * i <= _a; i++) {
        if (_a % i == 0) {
            ll j = _a / i;
            if (i <= n && j <= m) {
                cout << 2 << endl;
                return 0;
            }
        }
    }
    for (ll t = 1; t <= m; t++) {
        ll u = n * t, v = _a - u;
        ll mi = m - t, mx = n;
        if (mi > 0 && v > 0) {
            if (v % mi == 0 || v % mx == 0) {
                cout << 2 << endl;
                return 0;
            }
        }
        else break;
    }
    for (ll t = 1; t <= n; t++) {
        ll u = m * t, v = _a - u;
        ll mi = n - t, mx = m;
        if (mi > 0 && v > 0) {
            if (v % mi == 0 || v % mx == 0) {
                cout << 2 << endl;
                return 0;
            }
        }
        else break;
    }
    cout << 3 << endl;
    return 0;


问题 G: Hot Hike

时间限制: 1 Sec 内存限制: 128 MB


题目描述


In order to pass time during your vacation, you decided to go on a hike to visit a scenic lake up in the mountains. Hiking to the lake will take you a full day, then you will stay there for a day to rest and enjoy the scenery, and then spend another day hiking home, for a total of three days. However, the accursed weather this summer is ridiculously warm and sunny, and since severe dehydration is not at the top of your priority list you want to schedule the three-day trip during some days where the two hiking days are the least warm. In particular you want to minimize the maximum temperature during the two hiking days.

Given the current forecast of daily maximum temperatures during your vacation, what are the best days for your trip?


输入


The first line of input contains an integer n (3 ≤ n ≤ 50), the length of your vacation in days. Then follows a line containing n integers t1 , t2 , . . . , tn (−20 ≤ t i ≤ 40), where ti is the temperature forecast for the i’th day of your vacation.


输出


Output two integers d and t, where d is the best day to start your trip, and t is the resulting maximum temperature during the two hiking days. If there are many choices of d that minimize the value of t, then output the smallest such d.


样例输入 Copy


5
23 27 31 28 30


样例输出 Copy


2 28


不再赘述

int minn=inf,tag=-1;
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<n-1;i++)
    {
        if(minn>max(a[i],a[i+2]))
        {
            tag=i;
            minn=max(a[i],a[i+2]);
        }
    }
    cout<<tag<<" "<<minn<<endl;


问题 F: Game of Gnomes

时间限制: 1 Sec 内存限制: 128 MB


题目描述


The enemy and their massive army is approaching your fortress, and all you have to defend it is a legion of guardian gnomes. There is no hope of winning the battle, so your focus will instead be on causing as much damage as possible to the enemy.

You have n gnomes at your disposal. Before the battle, they must be divided into at most m non-empty groups. The battle will then proceed in turns. Each turn, your gnomes will attack the enemy, causing one unit of damage for each living gnome. Then the enemy will attack by throwing a lightning bolt at one of the m groups. The lightning bolt kills k of the gnomes in that group, or all of them if the number of living gnomes in the group is less than k. The battle ends when all gnomes are dead. The enemy will always throw the lightning bolts in an optimal way such that the total damage caused by the gnomes is minimized.

Now you wonder, what is the maximum amount of damage you can cause to the enemy if you divide the gnomes into groups in an optimal way?

For example, if as in Sample Input 1 you have n = 10 gnomes that are to be divided into m = 4 groups, and the lightning bolt does at most k = 3 damage, then an optimal solution would be to create one large group of size 7 and three small groups of size 1. In the first round, you cause 10 damage and the lightning bolt reduces the large group by 3. In the next round, you cause 7 damage and the large group is reduced down to size 1. In the remaining four rounds you do 4, 3, 2, and 1 damage respectively and the lightning bolt removes one group each round. In total you do 10 + 7 + 4 + 3 + 2 + 1 = 27 damage.


输入


The input consists of a single line containing the three integers n, m, and k (1 ≤ n ≤ 109 ,1 ≤ m, k ≤ 107 ), with meanings as described above.


输出


Output the maximum amount of damage you can cause to the enemy.


样例输入 Copy


10 4 3


样例输出 Copy


27


这是一道比较不错的涉及数学的贪心构造思维题;

学长的博客讲解很详细

  ll n, m, k;
  cin >> n >> m >> k;
  ll i = (n / k - m) - 10;
  if (i < 0) i = 0;
  for (; i <= n / k; i++) {
    if (n - i * k >= m * k) continue;
    ll t1 = n - (i - 1) * k;
    ll max1 = (n + t1) * i / 2;
    ll rem = n - i * k;/// 剩余的
    ll tot = rem / m;/// 
    ll modd = rem % m;
    ll temp1 = (rem + (m - modd) * tot + tot + 1) * modd / 2;
    ll temp2 = (tot + (m - modd) * tot) * (m - modd) / 2;
    ll ans = max1 + temp1 + temp2;
    res = max(res, ans);
  }
  cout << res << endl;

更新中。。。。。。


目录
相关文章
|
3月前
|
机器学习/深度学习 数据采集 算法
【 2021 MathorCup杯大数据挑战赛 A题 二手车估价】初赛复赛总结、方案代码及论文
总结了2021 MathorCup杯大数据挑战赛A题“二手车估价”的初赛和复赛经验,包括题目要求、解题思路、所用方法和结果,提供了详细的数据分析、模型构建、论文撰写和工具使用技巧,并展示了初赛和复赛的论文。
66 2
|
3月前
【2023 华数杯全国大学生数学建模竞赛】 A题 隔热材料的结构优化控制研究 问题分析及完整论文
本文提供了2023年华数杯全国大学生数学建模竞赛A题的完整论文,深入分析了隔热材料的结构优化控制研究,包括建立数学模型、求解单根纤维的热导率、优化织物结构参数以及考虑对流换热影响的模型调整,旨在开发出具有更优隔热性能的新型织物。
77 0
【2023 华数杯全国大学生数学建模竞赛】 A题 隔热材料的结构优化控制研究 问题分析及完整论文
|
3月前
|
人工智能 算法 安全
【2023 年第十三届 MathorCup 高校数学建模挑战赛】C 题 电商物流网络包裹应急调运与结构优化问题 赛后总结之31页论文及代码
本文总结了2023年第十三届MathorCup高校数学建模挑战赛C题的解题过程,详细阐述了电商物流网络在面临突发事件时的包裹应急调运与结构优化问题,提出了基于时间序列预测、多目标优化、遗传算法和重要性评价模型的综合解决方案,并提供了相应的31页论文和代码实现。
77 0
|
6月前
|
算法 数据可视化 数据挖掘
JCR一区10.9分|单细胞:有一手数据的肿瘤课题组怎么冲高分文章
这篇文章介绍了在《肿瘤免疫疗法》杂志上发表的一项研究,该研究利用单细胞RNA测序技术揭示了肝细胞癌(HCC)中FABP1(脂肪酸结合蛋白1)依赖的免疫抑制环境。研究分析了II期和III期HCC患者样本的免疫细胞,发现FABP1在III期HCC的肿瘤相关巨噬细胞(TAMs)中过度表达,并与免疫抑制有关。FABP1与PPARG(过氧化物酶体增殖物激活受体伽玛)相互作用,促进了HCC中的脂肪酸氧化,进而影响免疫应答。
96 0
|
机器学习/深度学习 算法 数据可视化
“华为杯”第十八届中国研究生数学建模竞赛D题:抗乳腺癌候选药物的优化建模(一等奖)
“华为杯”第十八届中国研究生数学建模竞赛D题:抗乳腺癌候选药物的优化建模(一等奖)
213 0
|
机器学习/深度学习 算法 数据可视化
精准高效估计多人3D姿态,美图&北航分布感知式单阶段模型入选CVPR 2022
精准高效估计多人3D姿态,美图&北航分布感知式单阶段模型入选CVPR 2022
136 0
|
安全 数据挖掘 定位技术
2022年中国研究生数学建模竞赛F题 COVID-19疫情期间生活物资的科学管理问题思路分析
2022年中国研究生数学建模竞赛F题 COVID-19疫情期间生活物资的科学管理问题
6122 5
2021年度训练联盟热身训练赛第三场——C,G,I
2021年度训练联盟热身训练赛第三场——C,G,I
92 0
2021年度训练联盟热身训练赛第一场——Weird Flecks, But OK(最小圆覆盖)
2021年度训练联盟热身训练赛第一场——Weird Flecks, But OK(最小圆覆盖)
97 0
|
Go
2020中石油组队训练第八场记录(上)
问题 D: Eeny Meeny 时间限制: 2 Sec 内存限制: 128 MB 题目描述 “Eeny meeny miny moe” is a well-known nursery rhyme in English, used (among other things) by kids to “randomly” select members of a team. It exists in many variations, one of which goes like this: Eeny, meeny, miny, moe, Catch a tiger by the toe.
59 0
2020中石油组队训练第八场记录(上)
下一篇
无影云桌面