J - 数论,质因数分解

Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

Submit Status

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 <cstdio>
#include <cstring>
using namespace std;
int b[];
int n;
void p( )
{
int m=n;
while()
{
for(int i=;i<=n;i++ )
if(m%i==)
{
b[i]++;
m/=i;
break;
}
if(m==)
break;
} }
int main()
{
int Case=;
while(scanf("%d",&n)==&&n>)
{
if(Case>) printf("\n"); memset(b,,sizeof(b));
p();
printf("Case %d.\n",++Case);
for(int i=;i<=n;i++)
if(b[i]!=)
printf("%d %d ",i,b[i]);
printf("\n");
}
}

数学概念——J - 数论,质因数分解的更多相关文章

  1. HDU3988-Harry Potter and the Hide Story(数论-质因数分解)

    Harry Potter and the Hide Story Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 ...

  2. 数学概念——I - 数论,线性方程

    I - 数论,线性方程 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit  ...

  3. UVA 10892 LCM Cardinality(数论 质因数分解)

    LCM Cardinality Input: Standard Input Output: Standard Output Time Limit: 2 Seconds A pair of number ...

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

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

  5. 简单数论之整除&质因数分解&唯一分解定理

    [整除] 若a被b整除,即a是b的倍数,那么记作b|a("|"是整除符号),读作"b整除a"或"a能被b整除".b叫做a的约数(或因数),a ...

  6. Pairs Forming LCM (LightOJ - 1236)【简单数论】【质因数分解】【算术基本定理】(未完成)

    Pairs Forming LCM (LightOJ - 1236)[简单数论][质因数分解][算术基本定理](未完成) 标签: 入门讲座题解 数论 题目描述 Find the result of t ...

  7. 【BZOJ2227】【ZJOI2011】看电影 [组合数][质因数分解]

    看电影 Time Limit: 10 Sec  Memory Limit: 259 MB[Submit][Status][Discuss] Description 到了难得的假期,小白班上组织大家去看 ...

  8. [HNOI2008]明明的烦恼(prufer序列,高精度,质因数分解)

      prufer序列 定义 Prufer数列是无根树的一种数列.在组合数学中,Prufer数列由有一个对于顶点标过号的树转化来的数列,点数为n的树转化来的Prufer数列长度为n-2. 描述 eg 将 ...

  9. 求n!质因数分解之后素数a的个数

    n!质因数分解后P的个数=n/p+n/(p*p)+n/(p*p*p)+......直到n<p*p*p*...*p //主要代码,就这么点东西,数学真是厉害啊!幸亏我早早的就退了数学2333 do ...

随机推荐

  1. php_curl扩展在WINDOWS2003上如何添加

    一.使用星外PHP安装后 二.修改环境变量,PATH: c:\php;c:\php\ext;%SystemRoot%\system32;

  2. java.lang.Exception: Socket bind failed: [730048] ?????????×???(Э?é/???????/???)????í??

    严重: Error starting endpoint java.lang.Exception: Socket bind failed: [730048] ?????????×???(Э?é/???? ...

  3. NSString 的三种截取方法

    1.定义一个字符串a, 截取a 的某一个项目组,复制给b, b必须是int型 NSString *a = @"1.2.30"; int  b= [[a substringWithR ...

  4. c++实现的Array数据结构

    1.Array.h,Array<T>的定义 template <class T> class Array { protected: T *data; //一个指向数组数据的指针 ...

  5. 在CentOS 6.3中安装与配置JDK-7

    在CentOS 6.3中安装与配置JDK-7 来源:互联网 作者:佚名 时间:02-07 16:28:33 [大 中 小] 在CentOS-6.3中安装与配置JDK-7,有需要的朋友可以参考下 安装说 ...

  6. jQuery判断文本框是否为空

    1.引用jQuery库 <script src="/static/js/jquery_v1.6.1.js" type="text/javascript"& ...

  7. QTP10破解

    1. 下载QTP10.0版本 http://h30302.www3.hp.com/prdownloads/T6510-15063.zip?ordernumber=380454070&itemi ...

  8. js定位navigator.geolocation

    一.简介 html5为window.navigator提供了geolocation属性,用于获取基于浏览器的当前用户地理位置. window.navigator.geolocation提供了3个方法分 ...

  9. C#操作xml的3种方式

    C#操作Xml有很多种方式,这里写出个人常使用的三种方式 XmlDocument DataSet linq to xml  首先声明本次操作使用的xml文件:books.xml:内容如下 <?x ...

  10. javabean 简介

    javabean其实包含多个方面的含义.   Java语言开发的可重用组件 优点:1,代码简洁.2,HTML与Java分离,好维护.3,将常用程序写成可重用组件,避免重复.   特点:1,所有类放在同 ...