nowcoder_一个简单的问题_priority_queue

一个简单的问题

//
#include<bits/stdc++.h>
using namespace std;

typedef long long LL;

int main()
{
    LL n,m,k,i;
    while( cin>>n>>m>>k )
    {
        priority_queue< pair<LL,LL> > q;
        pair< LL,LL > tt;

        for( i=1;i<=n;i++ ) // i*m: i*j_max i:j--
            q.push( make_pair( i*m,i ) );
        k--;
        while( k-- )        // --k != k--
        {
            tt=q.top(); q.pop();
            tt.first-=tt.second;
            q.push( tt );
        }
        tt=q.top();
        cout<<tt.first<<endl;
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_63173957/article/details/124849850