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. 利用VBS脚本实现Telnet自动连接

    把以下代码保存为*.vbs文件,替换IP.用户名.密码. Dim objShell Set objShell = CreateObject("Wscript.Shell") obj ...

  2. 【SIKIA计划】_04_C#中级教程 (2015版)笔记

    IKIC#中级教程 (2015版)正常模式指的是不会影响程序的正常运行.1,在VS中我们使用Console.Write(或者WriteLine)方法向控制台输出变量的值,通过这个我们可以查看变量的值是 ...

  3. Netty 粘包/拆包应用案例及解决方案分析

    熟悉TCP变成的可以知道,无论是客户端还是服务端,但我们读取或者发送消息的时候,都需要考虑TCP底层粘包/拆包机制,下面我们先看一下TCP 粘包/拆包和基础知识,然后模拟一个没有考虑TCP粘包/拆包导 ...

  4. VOT工具操作指南(踩过的坑)

    为了运行在VOT里DaSiamRPN,配置了很久环境,我电脑的配置是Ubuntu16.04+MatlabR2018a+pytorch0.3. 下面是一些从网上整理的操作步骤: 1.首先是工具箱的下载: ...

  5. 启动Nodejs服务

    vs code 中间创建 1.  settings.json { , { , { 'Content-Type': 'text/plain;charset=utf-8' })

  6. maven摘除jar包中配置文件

    <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-p ...

  7. LeetCode 655. Print Binary Tree (C++)

    题目: Print a binary tree in an m*n 2D string array following these rules: The row number m should be ...

  8. 【Alpha发布】贡献分分配

    最后贡献分分配: (1211)王嘉豪:32 (1186)黄雨萌:36 (1182)佘彦廷:40 (1208)何小松:50 (1200)鲁聃:62 (1174)邢浩:64 (1193)刘乾:66

  9. Javascript toString()、toLocaleString()、valueOf()三个方法的区别

    Array.Boolean.Date.Number等对象都具有toString().toLocaleString().valueOf()三个方法,那这三个方法有什么区别??? 一.JS Array 例 ...

  10. bug--注意Android编译打包--找不到某某类

    http://blog.csdn.net/mad1989/article/details/9142557 看到这篇 才解决问题= = 15,ClassNotFoundException: Didn't ...