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. mnist手写数字识别(决策树)

    import numpy as np from sklearn.neural_network import MLPClassifier from sklearn.linear_model import ...

  2. alibaba/Sentinel 分布式 系统流量防卫兵

    Sentinel: 分布式系统的流量防卫兵 Sentinel 是什么? 随着微服务的流行,服务和服务之间的稳定性变得越来越重要.Sentinel 以流量为切入点,从流量控制.熔断降级.系统负载保护等多 ...

  3. 基于Vue的简单通用分页组件

    分页组件是每一个系统里必不可少的一个组件,分页组件分为两部分.第一部分是模版部分,用于显示当前分页组件的状态,例如正在获取数据.没有数据.没有下一页等等:第二部分是分页数据对象,用于封装一个分页组件的 ...

  4. HTML基础范例

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. docker 下载安装与配置

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

  6. Django_WSGIRequest对象

    WSGIRequest对象 Django在接收到http请求之后,会根据http请求携带的参数以及报文信息创建一个WSGIRequest对象,并且作为视图函数第一个参数传给视图函数.这个参数就是dja ...

  7. 作业MathExam

    MathExam233 一.预估与实际 PSP2.1 Personal Software Process Stages 预估耗时(分钟) 实际耗时(分钟) Planning 计划 600 650 • ...

  8. CS小分队第二阶段冲刺站立会议(6月1日)

    昨日成果:完成了,文件图标的获取,以及代码删除获取文件的图标的功能:实现了从桌面拖动一个应用到窗体进行添加的功能: 遇到问题:获取的文件图标太小了,比较模糊:从外面拖动文件到窗体时,图标一直获取错误, ...

  9. Java 反射 不定参数bug

    遇到的第一个关于反射的bug:java.lang.IllegalArgumentException: wrong number of arguments的问题解析如下: 1.错误bug wrong n ...

  10. Mutual and feedback(互评与反馈)

    互评与反馈: 注:我在收集各小组对我小组的评价了,发现有几个没有收集到,不知道是我看不到还是贵小组不小心遗漏了对我小组的评价,如果看到,请给我留意,谢谢! 组名                  对我 ...