先找出所有的数,排序,然后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. AFNetworking 关于JSON text did not start with array or object and option to allow fragments not set 错误

    AFHTTPSessionManager *manager =[AFHTTPSessionManager manager]; [manager GET:@"http://www.baidu. ...

  2. 网络通信框架Apache MINA

    Apache MINA(Multipurpose Infrastructure for Network Applications) 是 Apache 组织一个较新的项目,它为开发高性能和高可用性的网络 ...

  3. How can I create an Asynchronous function in Javascript?

    哈哈:)我的codepen 的代码笔记是:http://codepen.io/shinewaker/pen/eBwPxJ --------------------------------------- ...

  4. json 与entity/list/map的转换

    一  json -> entity User.java package com.xxx.hotel.train.json.json2entity; import java.io.Serializ ...

  5. php 验证码类

    <?php  class Vcode {   private $width; //宽   private $height; //高   private $num;  //数量   private ...

  6. freemarker遍历list中的map

    前台: <select id="jq" name="jq" class="tsui" data-required="true ...

  7. 理解 bashrc 和 profile(转)

    转自:https://wido.me/sunteya/understand-bashrc-and-profile/ 在一般的 linux 或者 unix 系统中, 都可以通过编辑 bashrc 和 p ...

  8. ios ViewController的生命周期分析和基本使用逻辑

    按结构可以对iOS的所有ViewController分成两类:1.主要用于展示内容的ViewController,这种ViewController主要用于为用户展示内容,并与用户交互,如UITable ...

  9. [VC++]用CTime类得到当前日期、时间、星期,格式化(详细讲解)

    用CTime类得到当前日期.时间.星期,格式化(详细讲解)2009/05/12 09:48 A.M.① 定义一个CTime类对象 CTime time; ② 得到当前时间 time = CTime:: ...

  10. Android面试题集锦 (转)

    转自:http://xiechengfa.iteye.com/blog/1044721 一些常见的Android面试基础题做下总结,看看你能做出多少道? 1. Intent的几种有关Activity启 ...