您的位置:首页 > 其它

POJ 2545

2015-06-11 11:33 288 查看
#include<iostream>
#include<stdio.h>
#include<iomanip>
#define MAXN 100000
using namespace std;

double a[MAXN];
double x1 = 0;
double x2 = 0;
double x3 = 0;
void give_list(int x,int y,int z);
double min(double a,double b,double c);
int main()
{
//freopen("acm.acm","r",stdin);
double x;
double y;
double z;
int num;
cin>>x>>y>>z>>num;
give_list(x,y,z);
cout<<setiosflags(ios::fixed)<<setprecision(0)<<a[num]<<endl;
}

///////////////////////////////////////////////////////
//由2,3,5,7的乘积组成的数列,由小到大!第一个数默认是1!
///////////////////////////////////////////////////////
void give_list(int x,int y,int z)
{
a[0]=1;
int len;
double m;
len=1;
while(len <= MAXN)//核心的代码,产生器!
{
m=min(a[int(x1)]*x,a[int(x2)]*y,a[int(x3)]*z);
if(m==a[int(x1)]*x)x1++;
if(m==a[int(x2)]*y)x2++;
if(m==a[int(x3)]*z)x3++;
a[len++]=m;
}
}

double min(double a,double b,double c)//四个数中最小的;
{
a=a<b?a:b;
a=a<c?a:c;
return a;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: