Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

菜鸟70题纪念。。。code贴上。。。

Posted by LMagic at 2010-08-12 03:09:07 on Problem 1338
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;

const int fac[]={2,3,5};

int main()
{
    double x,ug[1507];
    int n;
    vector<double> h(1);
    h[0]=-1;
    for(int i=1;i<=1501;i++)
    {
       x=h[0];
       ug[i]=-x;
       pop_heap(h.begin(),h.end());
       h.pop_back();
       for(int j=0;j<3;j++)
       {
          if(find(h.begin(),h.end(),x*fac[j])==h.end())
          {
             h.push_back(x*fac[j]);
             push_heap(h.begin(),h.end());
          }
       }
    }
    while(cin>>n)
    {
       if(!n)
          break;
       printf("%.0lf\n",ug[n]);
    }
    return 0;
}

       

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator