USACO:Humble Numbers

/*
ID: Jang Lawrence
PROG: humble
LANG: C++
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define X first
#define Y second
#define sqr(a) ((a)*(a))
using namespace std;
typedef long long lng;
int k,n;
int s[111];
set q;
int main()
{
  #ifndef  DEBUG
  freopen("humble.in","r",stdin);
  freopen("humble.out","w",stdout);
  #endif
  scanf("%d%d",&k,&n);
  for(int i=0;i::iterator it=q.begin();
      while(1)
      {
          int t=(*it)*s[i];
          if(t<0) break;
          if(q.size()>n)
          {
              q.erase(--q.end());
              if(t>=*(--q.end())) break;
          }
          q.insert(t);
          ++it;
      }
  }
  printf("%d\n",*(--q.end()));
    return 0;
}

你可能感兴趣的:(usaco)