Description

Tomorrow is contest day, Are you all ready?  We have been training for 45 days, and all guys must be tired.But , you are so lucky comparing with many excellent boys who have no chance to attend the Province-Final. 
Now, your task is relaxing yourself and making the last practice. I guess that at least there are 2 problems which are easier than this problem.  what does this problem describe?  Give you a positive integer, please split it to some prime numbers, and you can got it through sample input and sample output. 
 

Input

Input file contains multiple test case, each case consists of a positive integer n(1<n<65536), one per line. a negative terminates the input, and it should not to be processed.
 

Output

For each test case you should output its factor as sample output (prime factor must come forth ascending ), there is a blank line between outputs.
 

Sample Input

60
12
-1
 

Sample Output

Case 1.
2 2 3 1 5 1

Case 2.
2 2 3 1

Hint

 60=2^2*3^1*5^1 

题意:如Hint所示.....,但是他的输出比较坑爹,开始一直不对然后没办法去百度了一下,大神说在输出结果最后还有空格,注意有空格!卧槽....  反正我是没有看出来

题解:就是求质因数,通过循环求质因数,如果n可以除尽i,进入while语句求i的次方,再用数组记录下来,最后在输出数组就好了...

代码如下:(详情见注释)
 #include <stdio.h>
int ans[];
int main()
{
int n,N=;
while(scanf("%d",&n)==&&n>=)
{
int j=;
if(N)
printf("\n"); //换行
N++;
for(int i=; i<=n; i++)
{
if(n%i==) //如果可以除尽
{
int m=; //注意清零
while(n%i==) //循环求 次数
{
m++;
n=n/i;
}
ans[j++]=i; //依次储存下来
ans[j++]=m;
}
}
printf("Case %d.\n",N); for(int k=; k<j; k++)
printf("%d ",ans[k]);  //输出
printf("\n");
}
}


HDU 1405 第六周 J题的更多相关文章

  1. hdu 4548 第六周H题(美素数)

    第六周H题 - 数论,晒素数 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u   De ...

  2. HDU 1465 第六周L题

    Description 大家常常感慨,要做好一件事情真的不容易,确实,失败比成功容易多了!  做好“一件”事情尚且不易,若想永远成功而总从不失败,那更是难上加难了,就像花钱总是比挣钱容易的道理一样.  ...

  3. HDU 2669 第六周 I题

    Description The Sky is Sprite.  The Birds is Fly in the Sky.  The Wind is Wonderful.  Blew Throw the ...

  4. hdu1405 第六周J题(质因数分解)

    J - 数论,质因数分解 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u   Desc ...

  5. 程序设计入门—Java语言 第六周编程题 1 单词长度(4分)

    第六周编程题 依照学术诚信条款,我保证此作业是本人独立完成的. 1 单词长度(4分) 题目内容: 你的程序要读入一行文本,其中以空格分隔为若干个单词,以'.'结束.你要输出这行文本中每个单词的长度.这 ...

  6. 2014 HDU多校弟六场J题 【模拟斗地主】

    这是一道5Y的题目 有坑的地方我已在代码中注释好了 QAQ Ps:模拟题还是练的太少了,速度不够快诶 //#pragma comment(linker, "/STACK:16777216&q ...

  7. Codeforces 559A 第六周 O题

    Description Gerald got a very curious hexagon for his birthday. The boy found out that all the angle ...

  8. 第六周 N题

    Description As Harry Potter series is over, Harry has no job. Since he wants to make quick money, (h ...

  9. HDU1465 第六周L题(错排组合数)

    L - 计数,排列 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u   Descrip ...

随机推荐

  1. iOS 导航栏颜色字体等的自定义

    1.设置导航栏中间文字的文字颜色和文字大小 方法一:系统方法 self.title = @"下载微课";//在有navigationController的控制器中,作用与self. ...

  2. 构建项目AppFuse+QuickStart

    AppFuse是一个完整的框架来构建web应用程序.它最初是为了构建新的web应用程序少走弯路.多年来,它已成为一个非常成熟的可测试和创建基于java的web应用安全系统.在其核心,AppFuse是项 ...

  3. kindeditor在JavaWeb中的应用

    KindEditor 是一套开源的在线HTML编辑器,主要用于让用户在网站上获得所见即所得编辑效果,开发人员可以用 KindEditor 把传统的多行文本输入框textarea替换为可视化的富文本编辑 ...

  4. javaweb学习总结二十五(response对象的用法一)

    一:Reponse对象的概念 当客户端发送http请求时,服务器端会对每一次请求,创建request对象和response对象. response对象包括三个部分:响应头.响应状态码以及响应体 二:r ...

  5. Linux chmod command

    @ chmod改变一个或多个文件的存取模式 chmod [options] mode files 只有文件属主或特殊用户才能使用该功能来改变文件存取模式.mode可以是数字形式或who opcode ...

  6. 2013 ACM/ICPC Asia Regional Online —— Warmup2

    HDU 4716 A Computer Graphics Problem 水题.略 HDU 4717 The Moving Points 题目:给出n个点的起始位置以及速度矢量,问任意一个时刻使得最远 ...

  7. HTTP协议状态码的含义

    HTTP协议状态码的含义 号码含义-----------------------------------------"100":Continue"101":wi ...

  8. freeCodeCamp:Search and Replace

    使用给定的参数对句子执行一次查找和替换,然后返回新句子. 第一个参数是将要对其执行查找和替换的句子. 第二个参数是将被替换掉的单词(替换前的单词). 第三个参数用于替换第二个参数(替换后的单词). 注 ...

  9. MVC 使用Jquery实现AJax

    View <script type="text/javascript"> function GetTime() { $.get("Home/GetTime&q ...

  10. MVC 下 使用MvcPager分页控件

    先去下载 mvcpage http://mvcpager.codeplex.com/releases/view/64098只需要一个 MvcPager.dll文件即可 然后引用MvcPager.dll ...