#include<iostream>
#include<stdio.h>
#include<iomanip>
#define MAXN 100000
using namespace std; double a[MAXN];
double x1 = ;
double x2 = ;
double x3 = ;
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 = ;
give_list(x,y,z);
int num;
while()
{
cin>>num;
if(num == )
break;
cout<<setiosflags(ios::fixed)<<setprecision()<<a[num-]<<endl;
}
} ///////////////////////////////////////////////////////
//由2,3,5,7的乘积组成的数列,由小到大!第一个数默认是1!
///////////////////////////////////////////////////////
void give_list(int x,int y,int z)
{
a[]=;
int len;
double m;
len=;
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;
}

关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。

技术网站地址: vmfor.com

POJ 1338的更多相关文章

  1. 递推(三):POJ中的三道递推例题POJ 1664、POJ 2247和POJ 1338

    [例9]放苹果(POJ 1664) Description 把M个同样的苹果放在N个同样的盘子里,允许有的盘子空着不放,问共有多少种不同的分法?(用K表示)5,1,1和1,5,1 是同一种分法. In ...

  2. [ACM训练] 算法初级 之 数据结构 之 栈stack+队列queue (基础+进阶+POJ 1338+2442+1442)

    再次面对像栈和队列这样的相当基础的数据结构的学习,应该从多个方面,多维度去学习. 首先,这两个数据结构都是比较常用的,在标准库中都有对应的结构能够直接使用,所以第一个阶段应该是先学习直接来使用,下一个 ...

  3. poj 1338 Ugly Numbers

    原题链接:http://poj.org/problem?id=1338 优先队列的应用,如下: #include<cstdio> #include<cstdlib> #incl ...

  4. poj 1338 Ugly Numbers(丑数模拟)

    转载请注明出处:viewmode=contents">http://blog.csdn.net/u012860063? viewmode=contents 题目链接:id=1338&q ...

  5. 51nod 1010 只包含因子2 3 5的数 && poj - 1338 Ugly Numbers(打表)

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1010 http://poj.org/problem?id=1338 首先 ...

  6. Poj 1338 Ugly Numbers(数学推导)

    一.题目大意 本题要求写出前1500个仅能被2,3,5整除的数. 二.题解 最初的想法是从1开始检验该数是否只能被2,3,5整除,方法是这样的,对于一个数,如果它能被2整除,就除以2,如果它能被3整除 ...

  7. POJ 2591 1338 2545 2247(数列递归衍生问题,思路挺妙)

    四道题的难度: 2591<1338<2545<2247 POJ 2591 Set Definition: 这是从discuss里看来的,写的挺好,直接copy,根据我的代码稍有改动( ...

  8. Poj 2247 Humble Numbers(求只能被2,3,5, 7 整除的数)

    一.题目大意 本题要求写出前5482个仅能被2,3,5, 7 整除的数. 二.题解 这道题从本质上和Poj 1338 Ugly Numbers(数学推导)是一样的原理,只需要在原来的基础上加上7的运算 ...

  9. 2013-2014集训之DP

    第一周: 经过漫长的时间,终于有时间来写一下结题报告. 地址http://acm.hust.edu.cn/vjudge/contest/view.action?cid=36180#overview A ...

随机推荐

  1. NOJ1012-进制转换

    进制转换 时间限制(普通/Java) : 1000 MS/ 3000 MS          运行内存限制 : 65536 KByte总提交 : 2214            测试通过 : 645  ...

  2. VC下的人人对弈五子棋(dos)

    #include"stdio.h"#include"stdlib.h"#include"string.h"#include "io ...

  3. PAT乙级真题1001. 害死人不偿命的(3n+1)猜想 (15)(解题)

    卡拉兹(Callatz)猜想: 对任何一个自然数n,如果它是偶数,那么把它砍掉一半:如果它是奇数,那么把(3n+1)砍掉一半.这样一直反复砍下去,最后一定在某一步得到n=1.卡拉兹在1950年的世界数 ...

  4. C++类实现三维数组算法

    在学习北京大学教授的<程序设计实习 / Practice on Programming>中,遇到了一个习题,花了很长时间研究,现在分享出来: 课题地址:https://class.cour ...

  5. Java Collections Source Code Series 1 --- 简介

    废话开篇 由于项目需要,需要对Java Collections进行系统地了解,所以在此记录下,方便自己,服务他人. Java Collections 简介 Java Collections 框架主要包 ...

  6. poj 2367 Genealogical tree

    题目连接 http://poj.org/problem?id=2367 Genealogical tree Description The system of Martians' blood rela ...

  7. 一、JPEG文件格式-----压缩框架

    JPEG文件格式 http://wenku.baidu.com/view/4856d31dc281e53a5802ff0d.html 标记名 FF E0                         ...

  8. WEB实时聊天 comet推技术

    转自:http://www.cnblogs.com/wodemeng/archive/2012/04/06/2435302.html 今天晚上朋友遇到web服务端推技术的问题,自己就查了下资料,学习了 ...

  9. 【Populating Next Right Pointers in Each Node II】cpp

    题目: Follow up for problem "Populating Next Right Pointers in Each Node". What if the given ...

  10. 【LRU Cache】cpp

    题目: Design and implement a data structure for Least Recently Used (LRU) cache. It should support the ...