POJ 2591 Set Definition
来源:互联网 发布:女网络歌手好听的歌 编辑:程序博客网 时间:2024/05/14 23:53
一道poj以前月赛的题,数据超大,用long long 超内存,换成int 3万多K水过。。。。。。。。。这道题和上午那道纠结了一天的题是一样的,所以这道题很快就A了。水同样类型的题,很有成就感,有木有!有木有!!!!!!题目:
Set Definition
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 8248 Accepted: 3765
Description
Set S is defined as follows:
(1) 1 is in S;
(2) If x is in S, then 2x + 1 and 3x + 1 are also in S;
(3) No other element belongs to S.
Find the N-th element of set S, if we sort the elements in S by increasing order.
(1) 1 is in S;
(2) If x is in S, then 2x + 1 and 3x + 1 are also in S;
(3) No other element belongs to S.
Find the N-th element of set S, if we sort the elements in S by increasing order.
Input
Input will contain several test cases; each contains a single positive integer N (1 <= N <= 10000000), which has been described above.
Output
For each test case, output the corresponding element in S.
Sample Input
100254
Sample Output
4181461ac代码:
#include <iostream>#include <cstdio>using namespace std;const int N=100005*100;int num[N];int min(int a,int b){ return a<b?a:b;}int main(){ //freopen("4.txt","r",stdin); num[1]=1; int p2,p3; p2=p3=1; int i=1; while(i<=10000001){ num[++i]=min(2*num[p2]+1,3*num[p3]+1);if(num[i]==2*num[p2]+1)p2++;if(num[i]==3*num[p3]+1)p3++; } int n; while(~scanf("%d",&n)){ printf("%d\n",num[n]); } return 0;}
- POJ 2591 Set Definition
- POJ 2591 Set Definition
- poj 2591 Set Definition
- poj 2591 Set Definition
- poj 2591 Set Definition【OJ实验】
- POJ 2591 Set Definition(数论)
- poj Set Definition
- Set Definition
- POJ 2591 Set Definition(我的水题之路——又一个丑数)
- 一类计算问题小结poj&hoj Set Definition ,Humble Numbers ,Ugly Numbers 因子构造法
- Set Definition(两个一次函数)
- poj2591 Set Definition(递推)
- Algorithm学习笔记 --- Set Definition(单调队列)
- POJ 2443 Set Operation
- POJ 2443 Set Operation
- POJ 3096 SET 练习
- 【map】【set】poj 3297
- POJ 1053 Set Me
- win2000进程虚拟内存数据搜索与修改
- VisionMobile:移动平台生态系统冲突报告(十五)Chapter C:Nokia:Symbian,MeeGo和Qt的故事
- MVC模式的设计思想
- 使用Xshell连接Linux
- freebsd机器DHCP
- POJ 2591 Set Definition
- VB.NET之旅(七)—脆弱的基类
- ant打jar包以及制作成bat文件双击运行
- VB.NET之旅(八)—接口
- VB.NET之旅(九)—接口继承
- sql server 2000/2005 script
- VB.NET之旅(十)—何时用接口
- 我的IT之路2011(一)
- 指针--