JUST SORT

We define  B  is a Divisor of one 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 in total.
Now you have to order all the integers from  1  to  100000 by the following rules: 
X  will come before  Y  if
(1)  the number of divisors of  X  is less than the number of divisors of Y
(2)  the number of divisors of  X  is equal to the number of divisors of  Y  and  X > Y.
there are many test cases.
Each case contains an integer n (1 ≤ n ≤ 100000).
For each case, print the case number and the nth number after ordering.
1
2
3
4
1000
Case 1: 1
Case 2: 99991
Case 3: 99989
Case 4: 99971
Case 5: 88741
<pre name="code" class="cpp">#include<cstdio>
#include<iostream>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
priority_queue<int>que[129];
const int n=100000;
int a[n+1],b[n+1];
void star(){
    fill(a,a+n+1,0);
    fill(b,b+n+1,0);
    for(int i=1;i<=n;i++){
        for(int j=1;i*j<=n;j++){
            a[i*j]++;
        }
    }
    for(int i=0;i<=n;i++){
        que[a[i]].push(i);
    }
    for(int k=1,i=1;i<=128;i++){
        while(!que[i].empty()){
            b[k++]=que[i].top();
            que[i].pop();
        }
    }
}
int main ()
{
    star();
    int k=1,t;
    while(~scanf("%d",&t))
        printf("Case %d: %d\n",k++,b[t]);
    return 0;
}




 
  
In Linux, the `sort` command is used to sort lines of text in a file or output of a command. It can sort the lines in ascending or descending order based on various criteria such as alphabetical order, numeric order, etc. The basic syntax of the `sort` command is: ``` sort [options] [file] ``` Here, `options` are the command-line options that modify the behavior of the `sort` command, and `file` is the name of the file to be sorted. If no file is specified, `sort` reads from standard input. Some commonly used options of the `sort` command are: - `-r`: Sort the lines in descending order. - `-n`: Sort the lines in numeric order. - `-u`: Remove duplicate lines. - `-k`: Sort by a specific field or column. For example, to sort the lines in a file named `example.txt` in ascending order, you can use the following command: ``` sort example.txt ``` To sort the lines in descending order, you can use the `-r` option: ``` sort -r example.txt ``` To sort the lines in numeric order, you can use the `-n` option: ``` sort -n example.txt ``` To remove duplicate lines, you can use the `-u` option: ``` sort -u example.txt ``` To sort by a specific field or column, you can use the `-k` option followed by the field or column number. For example, to sort by the second column, you can use the following command: ``` sort -k 2 example.txt ``` These are just a few examples of how the `sort` command can be used in Linux. The `sort` command is a powerful tool for manipulating text files and output in the Linux command line.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值