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 

求质因数,使用循环求,数组记录就好
#include"iostream"
#include"cstring"
#include"cstdio"
using namespace std;
const int maxn=+;
int vis[maxn];
int main()
{
int n,ans,ca=;
while(cin>>n&&n>=)
{
memset(vis,,sizeof(vis));
ans=n;
int i=;
while(n!=)
{
if(n%i==)
{
vis[i]++;
n/=i;
i=;
}
else
i++;
}
if(ca!=) cout<<endl;
cout<<"Case "<<ca++<<"."<<endl;
for(int j=;j<=ans;j++)
{
if(vis[j]!=) cout<<j<<" "<<vis[j]<<" ";
}
cout<<endl;
}
return ;
}
 

集训第六周 数学概念与方法 J题 数论,质因数分解的更多相关文章

  1. 集训第六周 数学概念与方法 数论 筛素数 H题

    Description 小明对数的研究比较热爱,一谈到数,脑子里就涌现出好多数的问题,今天,小明想考考你对素数的认识.  问题是这样的:一个十进制数,如果是素数,而且它的各位数字和也是素数,则称之为“ ...

  2. 集训第六周 数学概念与方法 概率 F题

    Submit Status Description Sometimes some mathematical results are hard to believe. One of the common ...

  3. 集训第六周 数学概念与方法 计数 排列 L题

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

  4. 集训第六周 数学概念与方法 数论 线性方程 I题

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

  5. 集训第六周 数学概念与方法 概率 N题

    N - 概率 Time Limit:4000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status ...

  6. 集训第六周 数学概念与方法 概率 数论 最大公约数 G题

    Description There is a hill with n holes around. The holes are signed from 0 to n-1. A rabbit must h ...

  7. 集训第六周 数学概念与方法 UVA 11181 条件概率

    http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18546 题意:有n个人会去超市,其中只有r个人会买东西,每个人独自买东西的概 ...

  8. 集训第六周 数学概念与方法 UVA 11722 几何概型

    ---恢复内容开始--- http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=31471 题意,两辆火车,分别会在[t1,t2],[ ...

  9. 集训第六周 古典概型 期望 D题 Discovering Gold 期望

    Description You are in a cave, a long cave! The cave can be represented by a 1 x N grid. Each cell o ...

随机推荐

  1. mybatis-plus 获取新增id

    <insert id="insert" parameterType="com.xxx.xxxx.pojo.User"> insert into t_ ...

  2. MySQL 一对多查询,合并多的一方的信息

    select   c.name,  (select   group_concat(name) from student   s   where  s.class_id =c.id ) from  cl ...

  3. [Usaco2005 Jan]Sumsets 求和

    Description Farmer John commanded his cows to search for different sets of numbers that sum to a giv ...

  4. 贪心+枚举/哈希表 HDOJ Trouble

    题目传送门 题意:5个集合,每个集合最多200个数字,问是否每个集合挑一个数加起来和为0. 分析:显然n^5的程序果断超时,甚至n^3logn的二分也过不了.想n^3的方法,既然判断有没有,那么可以将 ...

  5. 自定义View(12)绘制.9图片

    代码如下: // 绘制.9图片 void draw9Path(Canvas canvas){ //创建一个ninePatch的对象实例,第一个参数是bitmap.第二个参数是byte[],这里其实要求 ...

  6. 2016/10/29 Action类中execute方法的使用

    第一步:先配置web.xml文件 <filter> <filter-name>struts2</filter-name> <filter-class>o ...

  7. java中什么包不需要导入

    java中Math.random()*10;在math包中不需要导入: 即import java.lang.Math; 即lang下的所有包都不需要导入.

  8. 简单备份11g db (文件系统)

    1.more check.sqlsqlplus / as sysdba << EOF!banner start dbstartupselect name from v\$database; ...

  9. ASP.NET中图片验证码与js获取验证码的值

    现在的程序中,为了防止用户恶意点击,我们一般都会加上验证,现在比较普遍的是加上图片验证码或者手机短信验证.验证码一般都是防机器不防人,有效的防止了恶意点击. 那么在webform中如何生成动态的图片验 ...

  10. 块级元素的text-align对行内元素和果冻元素(inline-block)的作用

    块级元素社设置了text-align:center以后,对其直接行内元素/果冻元素.继承行内元素/果冻元素都会产生“居中效应”. <style> .test4{ text-align: c ...