Just Do It

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1552    Accepted Submission(s):
1036

Problem Description
Now we define a function F(x), which means the factors
of x. In particular, F(1) = 1,since 1 only has 1 factor 1, F(9) = 3, since 9 has
3 factors 1, 3, 9. Now give you an integer k, please find out the minimum number
x that makes F(x) = k.
 
Input
The first line contains an integer t means the number
of test cases.
The follows t lines, each line contains an integer k. (0 <
k <= 100).
 
Output
For each case, output the minimum number x in one line.
If x is larger than 1000, just output -1.
 
Sample Input
4
4
2
5
92
 
Sample Output
6
2
16
-1
翻译:输入k,求因子数为k的数最小是哪个。
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<string>
#include<vector>
#include<iostream>
#include<cstring>
#define inf 0x3f3f3f3f
using namespace std;
#define ll long long
const int maxx=1e6+; int cnt[maxx];///下标是自然数,内容是这个自然数有多少个因子
int ans[maxx];///下标是因子数,内容是含有这么多因子数最小是哪个数 void init()//埃氏筛打表
{
memset(ans,-,sizeof(ans));
memset(cnt,,sizeof(cnt));
for(int i=;i<maxx;i++)
{
for(int j=i;j<maxx;j=j+i)
{
cnt[j]++;
}
if( ans[ cnt[i] ]==- )///i从1开始,越变越大,因子数也会越来越多
ans[ cnt[i] ]=i;///ans的下标 第一次遇见 没有遇见过的因子数目,就把i传进去,此时的i最小
}
} int main()///hdu3189
{
init();
int t;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
if(ans[n]>)
printf("-1\n");
else
printf("%d\n",ans[n]);
}
return ;
}

hdu3189-Just Do It-(埃氏筛+唯一分解定理)的更多相关文章

  1. hdu1215-七夕节-(埃氏筛+唯一分解定理)

    七夕节 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...

  2. CodeForces - 385C Bear and Prime Numbers (埃氏筛的美妙用法)

    Recently, the bear started studying data structures and faced the following problem. You are given a ...

  3. cf1154G 埃氏筛应用

    直接用埃氏筛也可以做,但是这题写起来有点恶臭.. 更加简单的写法是直接枚举gcd=k,然后里面再枚举一次i*k,即找到k两个最小的倍数,看起来复杂度很高,但其实也是埃氏筛的复杂度 因为每次枚举gcd, ...

  4. 「CF779B」「LOJ#10201.」「一本通 6.2 练习 4」Sherlock and His Girlfriend(埃氏筛

    题目描述 原题来自:Codeforces Round #400 B. Sherlock 有了一个新女友(这太不像他了!).情人节到了,他想送给女友一些珠宝当做礼物. 他买了 nnn 件珠宝.第 iii ...

  5. [JXOI 2018] 游戏 解题报告 (组合数+埃氏筛)

    interlinkage: https://www.luogu.org/problemnew/show/P4562 description: solution: 注意到$l=1$的时候,$t(p)$就 ...

  6. 埃氏筛优化(速度堪比欧拉筛) + 洛谷 P3383 线性筛素数 题解

    我们一般写的埃氏筛消耗的时间都是欧拉筛的三倍,但是欧拉筛并不好想(对于我这种蒟蒻) 虽然 -- 我 -- 也可以背过模板,但是写个不会的欧拉筛不如写个简单易懂的埃氏筛 于是就有了优化 这个优化还是比较 ...

  7. 埃氏筛+线段树——cf731F

    从2e5-1依次枚举每个数作为主显卡,然后分段求比它大的数的个数,这里的复杂度是调和级数ln2e5,即埃氏筛的复杂度.. #include<bits/stdc++.h> using nam ...

  8. 数论(8):min_25 筛(扩展埃氏筛)

    min_25 筛介绍 我们考虑这样一个问题. \[ans=\sum_{i = 1}^nf(i)\\ \] 其中 \(1 \le n \le 10^{10}\) 其中 \(f(i)\) 是一个奇怪的函数 ...

  9. U138097 小鱼吃大鱼 埃氏筛

    题目描述 小P同学在养殖一种非常凶狠的鱼,而且与其他鱼类不同,这种鱼越大越温顺,反而小鱼最凶残.当两条鱼相遇时, 小鱼会不断撕咬大鱼,每一口都咬下与它自身等重的肉(小鱼保持体重不变),直到大鱼的体重小 ...

随机推荐

  1. django 解决css,js文件304导致无法加载显示问题

    这种情况一般会在windows系统下出现 1.前台.后台如果无法加载css等样式.(建议通过此办法来解决) 这是因为你安装的某些IDE 或者其他更改了注册表导致的系统的注册表\HKEY_CLASSES ...

  2. es6(10)--Set,Map(1)

    //Set { let list=new Set(); list.add(5);//添加 list.add(7); //属性size就是长度 console.log('size',list.size) ...

  3. TCP/IP_网络基础知识

    今天看到k8s的网络,顿感网络知识不是特别扎实,立马回头补一下Tcp-ip知识,顺便记录下学习的过程: 计算机与网络发展的7个阶段: 批处理时代(计算机按照顺序处理,50年代)->分时系统时代( ...

  4. Laravel-初体验笔记

    一直想学Laravel却动不了手,刚好需要研究一个workflow之类的功能,有个Laravel项目一个登陆就把我搞晕,看Laravel文档看的也不能看进去,直接新建个Laravel仿一个,动手搞起来 ...

  5. springBoot基本配置

    Spring Boot 基本配置 1.新建maven jar工程 使用依赖 <project xmlns="http://maven.apache.org/POM/4.0.0" ...

  6. 【python】python函数式编程、高阶函数

    1.map() : python内置的高阶函数,接收一个函数f和一个list,并通过把函数f依次作用在list的每个元素上,得到一个新的list并            返回. def f(x): r ...

  7. ADO.net之综合演练

    using ConsoleApplication4.App_Code; using System; using System.Collections.Generic; using System.Lin ...

  8. jenkins部署配置

    https://www.cnblogs.com/rslai/p/8135460.html 修改jenkins的默认端口号: https://blog.csdn.net/qq_32440951/arti ...

  9. windows服务器自动删除日志文件

    https://blog.csdn.net/u010050174/article/details/72510367 步骤: 1.新建 一个bat脚本 2.添加到window执行计划中,进行每日执行. ...

  10. 关于URI和URL的区别

    URI:统一资源标志符(Uniform Resource Identifier)URL:统一资源定位符(uniform resource location) URN = Universal Resou ...