【题意简述】:就是有这种一个序列。就拿当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. centos nginx uwsgi django

    doc link uwsgi link video link

  2. 框架—Mybatis搭建

    1:导包 完整jar包:mybatis核心包+依赖包+mysqljdbc驱动包 2. 建库建表 3.实体类 4.映射文件 一般dao的包下 5.主配置文件(mybatisconfig.xml) 一般s ...

  3. POJ 4118 开餐馆

    Description 北大信息学院的同学小明毕业之后打算创业开餐馆.现在共有n 个地点可供选择.小明打算从中选择合适的位置开设一些餐馆.这 n 个地点排列在同一条直线上.我们用一个整数序列m1, m ...

  4. 洛谷P4779 Dijkstra 模板

    这道题很久之前做过 今天复习(复读)一遍 有疑问的就是pair的专属头文件#include<utility> 但是据说iostream和vector等已经包含了这个 #include< ...

  5. 大数据学习——mapreduce程序单词统计

    项目结构 pom.xml文件 <?xml version="1.0" encoding="UTF-8"?> <project xmlns=&q ...

  6. laravel groupby分组问题。

    laravel 5.7使用groupBy分组查询时会提示一个错误,但是sql可以执行. 因为:mysql从5.7以后,默认开启了严格模式. 解决方法:将/config/database.php 中:关 ...

  7. Linux Notes:Linux下的远程登录协议及软件

    常见的远程登录协议 1.RDP(remote desktopp protocol)协议,windows远程桌面协议 2.telnet CLI 界面下远程管理,几乎所有的操作系统都有,数据明文传输,不安 ...

  8. .net中的协变和逆变

    百度:委托中的协变和逆变. 百度:.net中的协变和逆变. 协变是从子类转为父类. 逆变是从父类到子类. 这样理解不一定严谨或者正确.需要具体看代码研究.

  9. HDU1757-A Simple Math Problem,矩阵快速幂,构造矩阵水过

    A Simple Math Problem 一个矩阵快速幂水题,关键在于如何构造矩阵.做过一些很裸的矩阵快速幂,比如斐波那契的变形,这个题就类似那种构造.比赛的时候手残把矩阵相乘的一个j写成了i,调试 ...

  10. BZOJ 3175: [Tjoi2013]攻击装置

    捉水题真是捉上瘾了TUT Description 给定一个01矩阵,其中你可以在0的位置放置攻击装置.每一个攻击装置(x,y)都可以按照“日”字攻击其周围的 8个位置(x-1,y-2),(x-2,y- ...