Fork me on GitHub

还可以用指针++
#include <stdlib.h> #include <stdio.h> #include <math.h> #include<string.h> #include <algorithm> #include <queue> using namespace std; #define ll long long priority_queue<ll,vector<ll>,greater<ll> > pi; int main( ) { //freopen("in.txt","r",stdin); int i,j,before,zero,n,k,p2,p3,p5; ll a[1501],temp; p2=p3=p5=1; a[1]=1;j=1; pi.push(1);before=0; while( j<= 1500 ) { temp=pi.top(); pi.pop(); if(temp!=before) { a[j++]=temp; pi.push(temp*2); pi.push(temp*3); pi.push(temp*5); before=temp; } } while(scanf("%d",&n)!=EOF) printf("%lld\n",a[n]); return 0; }

 

posted on 2013-02-21 10:56  huashiyiqike  阅读(148)  评论(0编辑  收藏  举报