/ Randle /

记录详情

System Error


  
VJ4Error('ProblemDataNotFoundError', '题目 5df364b0f41362acd913f860 的数据未找到。', 'Randle', '5df364b0f41362acd913f860')

代码

//
//  main.cpp
//  1142 2ed.
//
//  Created by 27 on 2021/5/3.
//

#include <iostream>

using namespace std;
struct Node{
    long long data,times;
    Node(long long d = 0,long long t = 0):data(d),times(t){}
}node[100100];

long long n,k,low = 2,pos,cnt = 1,tmp,ind;
void quickSort(int low,int high);
int divide(int low,int high);
int main(int argc, const char * argv[]) {
    scanf("%lld%lld",&k,&n);
    for(int i = 1;i <= k;i++) scanf("%lld",&node[i].data);
    pos = k + 1;
    node[pos++] = node[1];
    node[k + 1].times = 1;
    node[0].data = 1;
    
    while(cnt < n){
        for(int i = low;i < pos;i++){
            if(i == low){
                tmp = node[i].data * node[node[i].times].data;
                ind = i;
            }
            else{
                if(tmp > node[i].data * node[node[i].times].data){
                    tmp = node[i].data * node[node[i].times].data;
                    ind = i;
                }
                else if(tmp == node[i].data * node[node[i].times].data) node[i].times++;
                else if(i > k && node[i].times <= 1) break;
            }
        }
        node[pos].data = tmp;
        node[pos++].times = 1;
        node[ind].times++;
        cnt++;
        if(ind <= k) low++;
        while(node[low].times > k) low++;
    }
    printf("%lld",node[pos - 1].data);
    return 0;
}

void quickSort(int low,int high)
{
    if(low >= high) return;
    
    int mid = divide(low,high);
    quickSort(mid + 1, high);
    quickSort(low, mid - 1);
}

int divide(int low,int high)
{
    Node k = node[low];
    do{
        while(low < high && node[high].data >= k.data) high--;
        if(low < high) node[low++] = node[high];
        while(low < high && node[low].data <= k.data) low++;
        if(low < high) node[high--] = node[low];
    }while(low != high);
    node[low] = k;
    return low;
}

信息

递交者
类型
递交
题目
丑数
题目数据
下载
语言
C++
递交时间
2021-05-03 15:46:15
评测时间
2021-05-03 15:46:15
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes