hdu---------3189-------------------
2016-01-12 18:22
260 查看
水体一个,但是这种做题的方法值得发扬光大............
意思大概是,,,,,,9的因子都有1 3 9 三个数字 4也有三个因子 现在输入一个3 你需要输出 4(因为4 是有三个因子的数字中最小的数字)....意思就是这 很简单打表遍历,,,,但是 遍历的时候想到了,,, 如果倒序 遍历的话,例如 便利到9发现有3个因子,
这时候数组赋值为 a[3]=9; 然后一会有到4了,也是4个因子 在此进行赋值 a[3]=4; 这样的话,,简单又弱智
Just Do It Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1122 Accepted Submission(s): 743 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
意思大概是,,,,,,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[1001],b,c; memset(a,0,sizeof(a)); for(i=1000;i>0;i--) { q=0; for(j=i;j>0;j--) { if(i%j==0) q++; } a[q]=i; } scanf("%d",&t); while(t--) { scanf("%d",&n); m=a ; if(m==0) m=-1; printf("%d\n",m); } return 0; }
相关文章推荐
- Unity3D中js与C#之间相互调用的解决办法
- csdn的体验也越来越好了,但是现在博客到segmentfault了。
- Educational Codeforces Round 5(A) 模拟
- 去除字符串中空格的方法(2016.1.12P141-2)
- 浏览器兼容问题 chrome iframe location href
- poj--1985--Cow Marathon(树的直径)
- 【转】Android仿QQ截图应用测试
- web导航栏点击跳转后的样式
- Spring 笔记
- poj--1985--Cow Marathon(树的直径)
- 我的收藏:一些技术相关网址(不断更新)
- Android MVP 学习
- 修改navigationBar的title颜色
- 让我们在编程时多知道点设计模式用来装B神马的
- 解决RHadoop错误:PipeMapRed.waitOutputThreads(): subprocess failed with code 1
- 艾瑞年度数据:在线视频
- 从最近热门的700M看广电有线的供给侧改革
- OCR和VD的转移
- C# Best Practices - Creating Good Properties
- 为Nginx配置图片防盗链