【题意简述】:就是有这种一个序列。就拿当p1 = 2,p2 = 3, p3 = 5,来举例。由这三个数为基准组成的序列是:

2,3,4,5,6,8,9,10,12……如今给你这个序列数组的下标,让你求得这个数组中,这个下标里的数是多少。

【分析】:2,3,4,5,6,8,9,10,12……这个序列式由2,3,5这三个数生成的,详细怎样生成,就是:

详见代码:

这里以POJ2545为例:

//弄清当中的逻辑关系,能够从最简单的2,3,5试着做起!
#include<iostream>
#include<algorithm>
using namespace std; int main()
{
long long p1,p2,p3;
int n;
long long H[100005];
int a1,a2,a3; while(cin>>p1>>p2>>p3>>n)
{
H[1] = 1;
a1=a2=a3=1;
for(int i = 2;i<=n+1;i++)
{
H[i] = min(p1*H[a1],min(p2*H[a2],p3*H[a3]));
if(H[i]==p1*H[a1]) a1++;
if(H[i]==p2*H[a2]) a2++;
if(H[i]==p3*H[a3]) a3++;
}
cout<<H[n+1]<<endl;
}
return 0;
}

另外三道题与这个相差无几,都是这个的变形

仅仅只是2247 注意输出的格式!

//  C++ 代码 题目本身非常easy。注意格式输出。!

#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std; int main()
{
int a1,a2,a3,a4;
int n;
long long humble[6000];
humble[1]=1;
a1=1;
a2=1;
a3=1;
a4=1;
for(int i=2;i<=5842;i++)
{
humble[i] = min(2*humble[a1],min(3*humble[a2],min(5*humble[a3],7*humble[a4])));
if(humble[i]==2*humble[a1])
a1++;
if(humble[i]==3*humble[a2])
a2++;
if(humble[i]==5*humble[a3])
a3++;
if(humble[i]==7*humble[a4])
a4++;
}
//string b;
while(1)
{
cin>>n;
if(n==0)
break;
if(n%10==1)
{
if(n%100==11)
cout<<"The "<<n<<"th"<<" humble number is "<<humble[n]<<"."<<endl;
else
cout<<"The "<<n<<"st"<<" humble number is "<<humble[n]<<"."<<endl;
} if(n%10==2)
{
if(n%100==12)
cout<<"The "<<n<<"th"<<" humble number is "<<humble[n]<<"."<<endl;
else
cout<<"The "<<n<<"nd"<<" humble number is "<<humble[n]<<"."<<endl;
} if(n%10==3)
{
if(n%100==13)
cout<<"The "<<n<<"th"<<" humble number is "<<humble[n]<<"."<<endl;
else
cout<<"The "<<n<<"rd"<<" humble number is "<<humble[n]<<"."<<endl;
} if(n%10>3||n%10==0)
cout<<"The "<<n<<"th"<<" humble number is "<<humble[n]<<"."<<endl; }
}

POJ  2591

// 39392K  141Ms
// 打表过得 =_=
#include<iostream>
#include<algorithm>
using namespace std;
int S[10000001]; int main()
{
int a,b,n;
S[1] = 1;
a = b = 1;
for(int i = 2;i<=10000000;i++)
{
S[i] = min(2*S[a]+1,3*S[b]+1);
if(S[i] == 2*S[a]+1) a++;
if(S[i] == 3*S[b]+1) b++;
}
while(cin>>n)
{
cout<<S[n]<<endl;
}
return 0;
}

POJ 2545+2591+2247+1338简单水题的更多相关文章

  1. [POJ 1000] A+B Problem 经典水题 C++解题报告 JAVA解题报告

        A+B Problem Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 311263   Accepted: 1713 ...

  2. HDOJ(HDU) 2090 算菜价(简单水题、)

    Problem Description 妈妈每天都要出去买菜,但是回来后,兜里的钱也懒得数一数,到底花了多少钱真是一笔糊涂帐.现在好了,作为好儿子(女儿)的你可以给她用程序算一下了,呵呵. Input ...

  3. POJ 1061 青蛙的约会 数论水题

    http://poj.org/problem?id=1061 傻逼题不多说 (x+km) - (y+kn) = dL 求k 令b = n-m ; a = x - y ; 化成模线性方程一般式 : Lx ...

  4. 【UVA - 1644 / POJ - 3518】Prime Gap(水题)

    Prime Gap 这里直接写中文了 Descriptions: 对于一个数n,若n为素数则输出0,否则找到距离n最小的两个素数,一个大于n,一个小于n,输出他们的差(正数) Input 多组输入 每 ...

  5. POJ 2014:Flow Layout 模拟水题

    Flow Layout Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 3091   Accepted: 2148 Descr ...

  6. 简单水题 POJ 2291 Rotten Ropes

    题目传送门 /* 我校oj的源题,看懂题意就很水,贴出来省的再敲:) */ #include <cstdio> #include <algorithm> #include &l ...

  7. POJ 1936 All in All 匹配, 水题 难度:0

    题目 http://poj.org/problem?id=1936 题意 多组数据,每组数据有两个字符串A,B,求A是否是B的子串.(注意是子串,也就是不必在B中连续) 思路 设置计数器cnt为当前已 ...

  8. POJ 3125 Printer Queue(队列,水题)

    题意:有多组数据,每组数据给出n,m,n表示需要打印的文件个数,m表示要打印的目标位置(m为0~n-1).    接下来给出n个数,第i个值对应第i-1个位置的优先级大小.    打印规则如下:    ...

  9. poj 1218 THE DRUNK JAILER【水题】

    THE DRUNK JAILER Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 25124   Accepted: 1576 ...

随机推荐

  1. AspNetCore容器化(Docker)部署(一) —— 入门

    一.docker注册安装 Windows Docker Desktop https://www.docker.com/products/docker-desktop Linux Docker CE h ...

  2. 解决Invalid bound statement (not found)(Mybatis的Mapper绑定问题)

    一.问题描述 使用mybatis的项目在本地可以正常运行,但当使用maven或Jenkins打包部署到服务器上时出现了绑定错误,异常信息为: org.apache.ibatis.binding.Bin ...

  3. 4.关于while循环的基础小练习

    1)使用while.if循环输入123456 8910 count = 0 while count < 10: count += 1 if count == 7: print('') else: ...

  4. 哈理工(HUST)第八届程序设计竞赛--小乐乐的组合数

    这道题目是一道数学题,我们可以假设n为7,m为14. 这样的话我们就可以很清晰地看到7和7可以拼接在一起,这是一对,然后是7和14拼接在一起,第二对. 我们可以直接让n/7,m/7,这样就是1*2,就 ...

  5. docker使用阿里云镜像仓库docker

    1:阿里云docker仓库 https://dev.aliyun.com/search.html 2:进去注册帐号后,点击自己的管理中心. 3:在管理中心点击加速器,右边面板会有你的加速地址,右边面板 ...

  6. 【struts2】学习笔记

    常见问题及注意事项: 1.下载struts2时,要看清所下载的版本,不同版本web.xml配置路径不同! 2. 导入jar包时,导入的包要完全准确,缺少或过多的会导致缺失或冲突! 3. Registe ...

  7. Hibernate入门(1)——环境搭建

    什么是Hibernate?为什么使用Hibernate?Hibernate有什么优缺点?网上很多大神的文章又详细又通俗易懂. 步骤: 1.创建数据库表格. 2.编写JavaBean实体类. 3.下载H ...

  8. JSP菜鸟之困

    我一直想把java一套系统学好... 之前寒假学了android......feel good 大四又把jsp补习了一边.....85 但是苦于没有做过实例..... 暑假学PS之间想恶补一下jsp. ...

  9. kissy学习

    http://docs.kissyui.com/1.4/docs/html/guideline/kmd.html

  10. pycharm配置git--图文教程

    1.     下载git客户端 2.     File->Default Setting-> Version Control->Git 3.     Path to Git exec ...