1 #include<iostream> 2 #include<stdio.h> 3 #include<iomanip> 4 #define MAXN 100000 5 using namespace std; 6 7 double a[MAXN]; 8 double x1 = 0; 9 double x2 = 0; 10 double x3 = 0; 11 void give_list(int x,int y,int z); 12 double min(double a,double b,double c); 13 int main() 14 { 15 //freopen("acm.acm","r",stdin); 16 double x; 17 double y; 18 double z; 19 int num; 20 cin>>x>>y>>z>>num; 21 give_list(x,y,z); 22 cout<<setiosflags(ios::fixed)<<setprecision(0)<<a[num]<<endl; 23 } 24 25 26 27 /////////////////////////////////////////////////////// 28 //由2,3,5,7的乘积组成的数列,由小到大!第一个数默认是1! 29 /////////////////////////////////////////////////////// 30 void give_list(int x,int y,int z) 31 { 32 a[0]=1; 33 int len; 34 double m; 35 len=1; 36 while(len <= MAXN)//核心的代码,产生器! 37 { 38 m=min(a[int(x1)]*x,a[int(x2)]*y,a[int(x3)]*z); 39 if(m==a[int(x1)]*x)x1++; 40 if(m==a[int(x2)]*y)x2++; 41 if(m==a[int(x3)]*z)x3++; 42 a[len++]=m; 43 } 44 } 45 46 double min(double a,double b,double c)//四个数中最小的; 47 { 48 a=a<b?a:b; 49 a=a<c?a:c; 50 return a; 51 }
时间: 2024-11-05 00:53:39