洛谷 p1080国王游戏 题解

本文详细解析了洛谷平台上的P1080国王游戏问题,探讨了算法思路和解决方案,帮助读者理解游戏逻辑并掌握相关编程技巧。
摘要由CSDN通过智能技术生成

国王游戏


#include<iostream>
#include<vector>
#include<string>
#include <algorithm>
#include <cstring>

/*P1080 国王游戏
输入
1 大臣数n
2 国王左手数 国王右手数
3-n+2 大臣左手数 大臣右手数

 输出
 获得金币最多的大臣获得金币数量
 */

using namespace std;

int king_left = 0, king_right = 0;
int minister_number = 0;
//int max_gold = 0;
int a_front[10005] = {
   0};
//int mem[1005] = {0};
int *max_gold = new int[5005];
int max_length = 0;

struct minister {
   
    int left_hand;
    int right_hand;
    int key_word;
//    int get_gold;
};

vector<minister> minister_each;

///*寻找最小序列的递归函数*/
//void find_min(){
   
//
//}

bool cmp(minister a, minister b) {
   
    return a.key_word < b.key_word;
}

/*大数乘法*/
int bigMul(int *temp_a_front, int a_front_szie, int left_hand) {
   
//    int result_size = a_front_szie + 1;
//    auto *result = new int[result_size];
    int give_a_number = a_front_szie;
    for (int i = 0; i < a_front_szie; i++) {
   
        temp_a_front[i] 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值