hdu---------3189-------------------
2024-09-30 14:37:01
水体一个,但是这种做题的方法值得发扬光大............
Just Do It Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others)
Total Submission(s): Accepted Submission(s): Problem Description
Now we define a function F(x), which means the factors of x. In particular, F() = ,since only has factor , F() = , since has factors , , . 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. ( < k <= ). Output
For each case, output the minimum number x in one line. If x is larger than , just output -. Sample Input Sample Output -
意思大概是,,,,,,9的因子都有1 3 9 三个数字 4也有三个因子 现在输入一个3 你需要输出 4(因为4 是有三个因子的数字中最小的数字)....意思就是这 很简单打表遍历,,,,但是 遍历的时候想到了,,, 如果倒序 遍历的话,例如 便利到9发现有3个因子,
这时候数组赋值为 a[3]=9; 然后一会有到4了,也是4个因子 在此进行赋值 a[3]=4; 这样的话,,简单又弱智
#include<stdio.h>
#include<string.h>
int main()
{
int q,i,j,m,n,t,a[],b,c;
memset(a,,sizeof(a));
for(i=;i>;i--)
{
q=;
for(j=i;j>;j--)
{
if(i%j==)
q++;
}
a[q]=i;
}
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
m=a[n];
if(m==)
m=-;
printf("%d\n",m);
}
return ;
}
最新文章
- Linux学习笔记1_用户和权限
- socket是什么?(翻译)
- 【jq】c#零基础学习之路(3)继承和虚方法
- Python GUI编程--Tkinter
- 20款免费响应式的 HTML5 网站模板下载
- 使用MVC和EF,在保存数据的时候报错:System.Data.Entity.Validation.DbEntityValidationException: 对一个或多个实体的验证失败。有关详细信息,请参阅“EntityValidationErrors”属性。
- Html5 Canvas transform setTransform
- Servlet编程-步步为营
- Injecting and Binding Objects to Spring MVC Controllers--转
- Leetcode_104_Maximum Depth of Binary Tree
- windows处理PHP定时任务
- 洗礼灵魂,修炼python(91)-- 知识拾遗篇 —— pymysql模块之python操作mysql增删改查
- Java 堆内存 新生代 (转)
- jQuery获取点击对象的父级
- scala语言中的case关键字在spark中的一个奇特使用
- java中的stream的Map收集器操作
- 北大POJ题库使用指南
- selenium&;phantomjs实战--漫话爬取
- [ 原创 ] Java基础8--什么叫做重载
- [Transducer] Make Transducer works for Iteratable collection and Object
热门文章
- SpringData,JPA,MongoDB,Solr,Elasticsearch底层逻辑关系
- Java的方法
- ORACLE DTRACE DOC
- 202. Segment Tree Query
- Memcache应用场景介绍
- MySQL 温故而知新--Innodb存储引擎中的锁
- Android之弹出多级菜单
- IOS报错:Unexpected ‘@’ in program
- [英语学习]王秒同学《21天TED英语精练团》
- 查源码分析 游标 写 需要 cursors 一切不看源码的代码引入都是定时炸弹的启动