链接:https://ac.nowcoder.com/acm/contest/331/G
来源:牛客网
炫酷数字
时间限制:C/C++ 2秒,其他语言4秒
空间限制:C/C++ 131072K,其他语言262144K
64bit IO Format: %lld题目描述
小希希望你构造一个最小的正整数,使得其有n个因子。
输入描述:
第一行一个整数T表示数据组数 每组数据第一行输入一个正整数n,表示其因子数。 n≤1,000,000
输出描述:
输出一行一个整数,表示你构造出的这个数。注意:你需要保证你构造的数≤1,000,000
示例1
输入
复制
2 4 5
输出
复制
6 16
老老实实水没过,直接输到本地,复制粘贴,过了。。。
#include
using namespace std;
#define LL long long
#define mod 998244353
#define MAXN 1000005
#define pai acos(-1)
int r[MAXN]={0,1,2,4,6,16,12,64,24,36,48,1024,60,4096,192,144,120,65536,180,262144,240,576,3072,0,360,1296,12288,900,960,0,720,0,840,9216,196608,5184,1260,0,786432,36864,1680,0,2880,0,15360,3600,0,0,2520,46656,6480,589824,61440,0,6300,82944,6720,0,0,0,5040,0,0,14400,7560,331776,46080,0,983040,0,25920,0,10080,0,0,32400,0,746496,184320,0,15120,44100,0,0,20160,0,0,0,107520,0,25200,0,0,0,0,0,27720,0,233280,230400,45360,0,0,0,430080,129600,0,0,50400,0,414720,0,60480,0,0,0,0,921600,0,0,55440,0,0,0,0,810000,100800,0,83160,0,0,0,322560,0,0,176400,0,0,0,0,181440,0,0,0,110880,0,0,0,0,0,226800,0,0,0,0,0,0,0,0,0,166320,0,352800,0,0,0,0,0,221760,0,0,0,0,0,0,0,967680,0,0,0,277200,0,0,0,0,0,0,0,0,705600,0,0,332640,0,0,0,0,0,0,0,498960,0,0,0,0,0,0,0,0,0,907200,0,0,0,0,0,554400,0,0,0,0,0,0,0,665280,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,720720,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int main()
{
int T;
scanf("%d",&T);
while(T--){
int x;
scanf("%d",&x);
printf("%d\n",r[x]?r[x]:-1);
}
return 0;
}
贴个io
#include
#include
using namespace std;
int main()
{
int a[10];
ifstream in("读入.txt");
for(int i=0;i<10;i++)
in>>a[i];
for(int i=0;i<10;i++)
cout<
正解:类似埃氏筛法
#include
int main(){
int a[1000005]={0},ans[1000005]={0},n,t;
scanf("%d",&t);
for(int i=1;i<=1000000;i++)
for(int j=i;j<=1000000;j+=i){
a[j]++;
if(ans[a[i]]==0) ans[a[i]]=i;
}
while(t--){
scanf("%d",&n);
if(ans[n]) printf("%d\n",ans[n]);
else printf("-1\n");
}
return 0;
}