炫酷数字

炫酷数字

https://ac.nowcoder.com/acm/contest/331/G

题目描述

小希希望你构造一个最小的正整数,使得其有n个因子。

输入描述:

第一行一个整数T表示数据组数

每组数据第一行输入一个正整数n,表示其因子数。

n1,000,000n≤1,000,000

T1,000,000T≤1,000,000

输出描述:

输出一行一个整数,表示你构造出的这个数。注意:你需要保证你构造的数1,000,000≤1,000,000,如果在这个范围里面无法构造出一个正整数满足条件,请输出-1。
示例1

输入

复制
2
4
5

输出

复制
6
16
 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define lson l,mid,rt<<1
 4 #define rson mid+1,r,rt<<1|1
 5 #define sqr(x) ((x)*(x))
 6 typedef long long ll;
 7 /*#ifndef ONLINE_JUDGE
 8         freopen("1.txt","r",stdin);
 9 #endif */
10 int tmp[1000005];
11 int ans[1000005];
12 
13 
14 
15 int main(){
16     for(int i=1;i<=1000005;i++){
17         ans[i]=-1;
18         for(int j=i;j<=1000005;j+=i){
19             tmp[j]++;
20         }
21     }
22     for(int i=1;i<=1000005;i++){
23         if(ans[tmp[i]]==-1){
24             ans[tmp[i]]=i;
25         }
26     }
27     int n;
28     int t;
29     scanf("%d",&t);
30     while(t--){
31         scanf("%d",&n);
32         printf("%d\n",ans[n]);
33     }
34 
35 }
View Code

猜你喜欢

转载自www.cnblogs.com/Fighting-sh/p/10343568.html
今日推荐