先找出所有的数,排序,然后o(1)效率询问

#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
using namespace std; long long Ans[];
int tot;
map<long long, int>Cun;
const long long INF = 1e18; void init()
{
tot = ;
Cun.clear();
Cun[] = ;
Ans[tot] = ;
} int main()
{
int head = ;
init();
while ()
{
if (Ans[head] == ) break;
long long h = Ans[head];
if (h * > INF || Cun[h * ] == ) {}
else
{
tot++;
Ans[tot] = h * ;
Cun[h * ] = ;
} if (h * > INF || Cun[h * ] == ){}
else
{
tot++;
Ans[tot] = h * ;
Cun[h * ] = ;
} if (h * > INF || Cun[h * ] == ) {}
else
{
tot++;
Ans[tot] = h * ;
Cun[h * ] = ;
} if (h * > INF || Cun[h * ] == ) {}
else
{
tot++;
Ans[tot] = h * ;
Cun[h * ] = ;
}
head++;
}
sort(Ans, Ans + tot + );
int T;
scanf("%d", &T);
while (T--)
{
int n;
scanf("%d", &n);
printf("%lld\n", Ans[n - ]);
}
return ;
}

POJ 3307 Smart Sister的更多相关文章

  1. poj 3307 Smart Sister 打表解因子生成数问题

    题意: 给i,求由仅以2,3,5,7为因子的数中第i个是多少. 分析: 打表. 代码: //poj 3307 //sep9 #include <iostream> using namesp ...

  2. (01背包变形) Cow Exhibition (poj 2184)

    http://poj.org/problem?id=2184   Description "Fat and docile, big and dumb, they look so stupid ...

  3. POJ - 2339 Rock, Scissors, Paper

    初看题目时就发了个错误,我因为没有耐心看题而不了解题目本身的意思,找不到做题的突破口,即使看了一些题解,还是没有想到方法. 后来在去问安叔,安叔一语道破天机,问我有没有搞清题目的意思,我才恍然大悟,做 ...

  4. POJ 3974 Palindrome

    D - Palindrome Time Limit:15000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Sub ...

  5. POJ 3104 Drying(二分答案)

    题目链接:http://poj.org/problem?id=3104                                                                  ...

  6. POJ 2960 博弈论

    题目链接: http://poj.org/problem?id=2960 S-Nim Time Limit: 2000MS Memory Limit: 65536K 问题描述 Arthur and h ...

  7. 【POJ 3162】 Walking Race (树形DP-求树上最长路径问题,+单调队列)

    Walking Race   Description flymouse's sister wc is very capable at sports and her favorite event is ...

  8. [POJ 2184]--Cow Exhibition(0-1背包变形)

    题目链接:http://poj.org/problem?id=2184 Cow Exhibition Time Limit: 1000MS   Memory Limit: 65536K Total S ...

  9. poj 1012——Toseph

    提交地址:http://poj.org/problem?id=1012                                                                 ...

随机推荐

  1. python-连接数据库

    from sqlalchemy import create_engine,text,Column,Integer,String,Sequencefrom sqlalchemy.ext.declarat ...

  2. mysql创建计算列

    mysql> create table t(id int auto_increment not null,c1 int,c2 int,c3 int as (c1+c2),primary key( ...

  3. mysql5.7.16安装

    系统:centOS6.5 mysql: 5.7.16 wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.16-linux-glib ...

  4. lucene 索引创建步骤

    一.步骤: 1.存储位置:1)文件: Directory dir= FSDirectory.open(new File("D:\\LuceneIndex")); 2)内存: new ...

  5. iOS学习笔记(01) - 泛型

    决定新开一坑,在不断学习的同时分享自己的学习历程给大家,既是对自己学习的记录,又希望能对大家提供些微的帮助. 这一篇文章主要来介绍泛型的意义.使用与声明方法等. 1.泛型:限制类型 1.1.泛型使用场 ...

  6. asp脱离源代码管理

    当项目中出现“未能找到与此解决方案关联的源代码管理提供程序.项目将视为不受源代码管理” 解决方法:1.vs2013打开项目, 2.提示“您正在打开的解决方案已绑定到以下Team Foundation ...

  7. HDU 3416 Marriage Match IV

    最短路+最大流 #include<cstdio> #include<cstring> #include<string> #include<cmath> ...

  8. R语言笔记5--读数据

    1.读文本文件数据 (1)先设置工作目录,把文本文件放于该目录下 备注:在记事本里写完数据后,按一下回车,负责在R语言中出现错误 (2)读剪贴板 文本或EXCEL的数据均可通过剪贴板操作 (3)读ex ...

  9. C++ 中Hello World的一种写法

    /*C++ Hello World**/#include <stdio.h>#include <iostream>int main(){    printf("Hel ...

  10. [实用]DNS解析命令,静静地学会【转载】

    [实用]DNS解析命令,静静地学会 2016-08-04 06:50 一.Windows下的nslookup 简单的查某个域名,那就nslookup toutiao.com,上面是dns地址,下面是解 ...