数学概念——J - 数论,质因数分解
Description
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
Output
Sample Input
Sample Output
2 2 3 1 5 1
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 - 数论,质因数分解的更多相关文章
- HDU3988-Harry Potter and the Hide Story(数论-质因数分解)
Harry Potter and the Hide Story Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 ...
- 数学概念——I - 数论,线性方程
I - 数论,线性方程 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit ...
- UVA 10892 LCM Cardinality(数论 质因数分解)
LCM Cardinality Input: Standard Input Output: Standard Output Time Limit: 2 Seconds A pair of number ...
- hdu1405 第六周J题(质因数分解)
J - 数论,质因数分解 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Desc ...
- 简单数论之整除&质因数分解&唯一分解定理
[整除] 若a被b整除,即a是b的倍数,那么记作b|a("|"是整除符号),读作"b整除a"或"a能被b整除".b叫做a的约数(或因数),a ...
- Pairs Forming LCM (LightOJ - 1236)【简单数论】【质因数分解】【算术基本定理】(未完成)
Pairs Forming LCM (LightOJ - 1236)[简单数论][质因数分解][算术基本定理](未完成) 标签: 入门讲座题解 数论 题目描述 Find the result of t ...
- 【BZOJ2227】【ZJOI2011】看电影 [组合数][质因数分解]
看电影 Time Limit: 10 Sec Memory Limit: 259 MB[Submit][Status][Discuss] Description 到了难得的假期,小白班上组织大家去看 ...
- [HNOI2008]明明的烦恼(prufer序列,高精度,质因数分解)
prufer序列 定义 Prufer数列是无根树的一种数列.在组合数学中,Prufer数列由有一个对于顶点标过号的树转化来的数列,点数为n的树转化来的Prufer数列长度为n-2. 描述 eg 将 ...
- 求n!质因数分解之后素数a的个数
n!质因数分解后P的个数=n/p+n/(p*p)+n/(p*p*p)+......直到n<p*p*p*...*p //主要代码,就这么点东西,数学真是厉害啊!幸亏我早早的就退了数学2333 do ...
随机推荐
- HTML5 ArrayBufferView之DataView
DataView视图 如果一段数据包括多种类型(比如服务器传来的HTTP数据),这时除了建立ArrayBuffer对象的复合视图以外,还可以通过DataView视图进行操作. DataView视图提供 ...
- .Net framework.
Figure 1 - .Net Framework The Common Language Runtime (CLR) is the mechanism through which .NET code ...
- linq学习笔记:将List<T> 转换为 Dictionary<T Key,T Value>
运用Linq,将List<T> 转换为 Dictionary<T Key,T Value> 即:List<T> ToDictionary<T Key,T V ...
- awr相关指标解析
awr相关指标解析 2016年11月11日 15:09
- index full scan/index fast full scan/index range scan
**************************1************************************* 索引状态: valid. N/A . ...
- AppStore上架规则
1. 条款和条件1.1 为App Store开发程序,开发者必须遵守 Program License Agreement (PLA).人机交互指南(HIG)以及开发者和苹果签订的任何协议和合同.以下规 ...
- hdoj 2040
#include<stdio.h>int i,j,s1,s2;int cha(int a,int b){ s1=0; s2=0; for(i=1;i<a;i++) { ...
- js中立即执行
( function(){…} )()和( function (){…} () )是两种javascript立即执行函数的常见写法,最初我以为是一个括号包裹匿名函数,再在后面加个括号调用函数,最后达到 ...
- linxu 挂载分区
1. 添加新硬盘 设置 -> Storage -> SATA控制器->右击,选择“添加虚拟硬盘” 然后,根据需求创建合适的硬盘 2. 重启虚拟机 查看现有系统的磁盘空间 sudo f ...
- sql查询一个班级中总共有多少人以及男女分别多少人
--创建视图 create view StuClassView as SELECT s.ID ,s.StuName ,s.StuAge ,s.StuAddress ,s.StuTel ,s.Class ...