We define b is a Divisor of a number a if a is divisible by b. So, the divisors of 12 are 1, 2, 3, 4, 6, 12. So, 12 has 6 divisors.

Now you have to order all the integers from 1 to 1000. x will come before y if

1)                  number of divisors of x is less than number of divisors of y

2)                  number of divisors of x is equal to number of divisors of y and x > y.

Input

Input starts with an integer T (≤ 1005), denoting the number of test cases.

Each case contains an integer n (1 ≤ n ≤ 1000).

Output

For each case, print the case number and the nth number after ordering.

Sample Input

5

1

2

3

4

1000

Sample Output

Case 1: 1

Case 2: 997

Case 3: 991

Case 4: 983

Case 5: 840

直接分解质因子 暴力就好了。。。

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#define rap(a, n) for(int i=1; i<=n; i++)
#define MOD 2018
#define LL long long
#define ULL unsigned long long
#define Pair pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define _ ios_base::sync_with_stdio(0),cin.tie(0)
//freopen("1.txt", "r", stdin);
using namespace std;
const int maxn = , INF = 0x7fffffff;
int primes[maxn], vis[maxn], sum[maxn];
int ans; struct node
{
int id, xi;
}Node[maxn]; void init()
{
mem(vis, );
for(int i=; i<maxn; i++)
{
if(vis[i]) continue;
primes[ans++] = i;
for(LL j = (LL)i*i; j<maxn; j+=i)
vis[j] = ;
}
} bool cmp(node a, node b)
{
if(a.xi == b.xi)
return a.id > b.id;
return a.xi < b.xi;
} int main()
{
ans = ;
init();
rap(, )
{
Node[i].id = i;
Node[i].xi = ;
int temp = i;
for(int j=; j<ans && primes[j] * primes[j] <= temp; j++)
{
int cnt2 = ;
while(temp % primes[j] == )
{
temp /= primes[j];
cnt2++;
}
if(cnt2 > )
Node[i].xi *= (cnt2+);
}
if(temp > )
Node[i].xi *= ;
}
sort(Node+, Node++, cmp);
int T, kase = ;
cin>> T;
while(T--)
{
int n;
cin>> n;
printf("Case %d: %d\n",++kase, Node[n].id);
} return ;
}

False Ordering LightOJ - 1109(暴力。。唉,。又是一个水题。。)的更多相关文章

  1. lightoj 1148 Mad Counting(数学水题)

    lightoj 1148 Mad Counting 链接:http://lightoj.com/volume_showproblem.php?problem=1148 题意:民意调查,每一名公民都有盟 ...

  2. POJ 2260(ZOJ 1949) Error Correction 一个水题

    Description A boolean matrix has the parity property when each row and each column has an even sum, ...

  3. 又是一道水题 hdu背包

    Problem Description 电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额.如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上余额为负) ...

  4. ZJU 1180 Self Numbers(暴力模拟判断,水题)

    题目链接 同HDU 1128 , POJ 1316(这个范围小一点). 原本怕超时,以为有技巧或者规律,死命的想,后来发现这就是一道水体,模拟着全部判断一下就好了,10秒呢,完全不怕超时...唔,废话 ...

  5. 返回一个集合对象,同时这个集合的对象的属性又是一个集合对象的处理方法(ViewModel)

    如果遇到需要返回一个集合对象,其中该集合中的属性又是一个集合.第一种:可在考虑用外键关联,比如在控制器中可以采用预先加载的方式加载关联的数据,比如 RoleManager.Roles.Include& ...

  6. python基础练习题(一个整数,它加上100后是一个完全平方数,再加上168又是一个完全平方数,请问该数是多少?)

    day2 --------------------------------------------------------------- 实例003:完全平方数 题目: 一个整数,它加上100后是一个 ...

  7. Uva 10305 - Ordering Tasks 拓扑排序基础水题 队列和dfs实现

    今天刚学的拓扑排序,大概搞懂后发现这题是赤裸裸的水题. 于是按自己想法敲了一遍,用queue做的,也就是Kahn算法,复杂度o(V+E),调完交上去,WA了... 于是检查了一遍又交了一发,还是WA. ...

  8. [Usaco2008 Feb]Line连线游戏[暴力][水题]

    Description Farmer John最近发明了一个游戏,来考验自命不凡的贝茜.游戏开始的时 候,FJ会给贝茜一块画着N (2 <= N <= 200)个不重合的点的木板,其中第i ...

  9. PAT甲题题解-1019. General Palindromic Number (20)-又是水题一枚

    n转化为b进制的格式,问你该格式是否为回文数字(即正着写和倒着写一样)输出Yes或者No并且输出该格式又是水题... #include <iostream> #include <cs ...

随机推荐

  1. 图片隐写--XOR&OR&and

    图片xor的脚本 和图片进行xor or and 运算的脚本 from PIL import Image #import pil def loadImage(filename): img = Imag ...

  2. php的id加密

    <?php/** * article url:http://kvz.io/blog/2009/06/10/create-short-ids-with-php-like-youtube-or-ti ...

  3. Jenkins远程测试

    Jenkins远程测试 网络测试,如,selenium 测试可以通过主从和 selenium 套件插件远程安装在机器上运行.下列步骤显示了如何运行使用此配置来进行远程测试. 第1步 - 确保主从配置到 ...

  4. docker 下载安装与配置

    # mac离线安装dockerhttps://download.docker.com/mac/stable/24312/Docker.dmg # windows离线安装dockerhttp://mir ...

  5. Django数据库 相关之select_related/prefetch_related

    - 性能相关 user_list = models.UserInfo.objects.all() for row in user_list: # 只去取当前表数据 select_related,主动连 ...

  6. rev命令详解

    基础命令学习目录首页 rev命令将文件中的每行内容以字符为单位反序输出,即第一个字符最后输出,最后一个字符最先输出,依次类推. #cat a.txt wo shi mcw, nihao how do ...

  7. du命令详解

    基础命令学习目录首页 原文链接:https://blog.csdn.net/linuxnews/article/details/51207738 导读du命令是检查硬盘使用情况,统计文件或目录及子目录 ...

  8. 如何在静态方法或非Spring Bean中注入Spring Bean

           在项目中有时需要根据需要在自己new一个对象,或者在某些util方法或属性中获取Spring Bean对象,从而完成某些工作,但是由于自己new的对象和util方法并不是受Spring所 ...

  9. 快速删除docker中的容器

    http://blog.csdn.net/cmzsteven/article/details/49230363

  10. centos下配置gitosis服务器遇到的困难

    这篇博客主要讲的是在centos下配置gitosis遇到的问题. 背景:centos7.2 64 :gitosis2.0 1.困难1 1)产生的问题及原因.gitosis没有安装成功,没有出现fini ...