集训第六周 数学概念与方法 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
12
-1
Sample Output
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题 数论,质因数分解的更多相关文章
- 集训第六周 数学概念与方法 数论 筛素数 H题
Description 小明对数的研究比较热爱,一谈到数,脑子里就涌现出好多数的问题,今天,小明想考考你对素数的认识. 问题是这样的:一个十进制数,如果是素数,而且它的各位数字和也是素数,则称之为“ ...
- 集训第六周 数学概念与方法 概率 F题
Submit Status Description Sometimes some mathematical results are hard to believe. One of the common ...
- 集训第六周 数学概念与方法 计数 排列 L题
Description 大家常常感慨,要做好一件事情真的不容易,确实,失败比成功容易多了! 做好“一件”事情尚且不易,若想永远成功而总从不失败,那更是难上加难了,就像花钱总是比挣钱容易的道理一样. 话 ...
- 集训第六周 数学概念与方法 数论 线性方程 I题
Description The Sky is Sprite. The Birds is Fly in the Sky. The Wind is Wonderful. Blew Throw the Tr ...
- 集训第六周 数学概念与方法 概率 N题
N - 概率 Time Limit:4000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit Status ...
- 集训第六周 数学概念与方法 概率 数论 最大公约数 G题
Description There is a hill with n holes around. The holes are signed from 0 to n-1. A rabbit must h ...
- 集训第六周 数学概念与方法 UVA 11181 条件概率
http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18546 题意:有n个人会去超市,其中只有r个人会买东西,每个人独自买东西的概 ...
- 集训第六周 数学概念与方法 UVA 11722 几何概型
---恢复内容开始--- http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=31471 题意,两辆火车,分别会在[t1,t2],[ ...
- 集训第六周 古典概型 期望 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 ...
随机推荐
- python之logging模块简单用法
前言: python引入logging模块,用来记录自己想要的信息.print也可以输入日志,但是logging相对print来说更好控制输出在哪个地方.怎么输出以及控制消息级别来过滤掉那些不需要的信 ...
- Oracle10g初探DBCA
Database Configuration Assistant. [oracle@dbsrv3 bin]$ pwd /opt/oracle//bin [oracle@dbsrv3 bin]$ ./d ...
- Service官方教程(10)Bound Service的生命周期函数
Managing the Lifecycle of a Bound Service When a service is unbound from all clients, the Android sy ...
- C# 基础知识和VS2010的小技巧总汇
看了一些基础视频,才发现自己的基础比较薄弱,有很多基础知识都不知道.这里总汇一些基础知识. 1: foreach不仅可以作用于list类的索引集合,还可以遍历dictionary类,这一点比for更简 ...
- 448 Find All Numbers Disappeared in an Array 找到所有数组中消失的数字
给定一个范围在 1 ≤ a[i] ≤ n ( n = 数组大小 ) 的 整型数组,数组中的元素一些出现了两次,另一些只出现一次.找到所有在 [1, n] 范围之间没有出现在数组中的数字.您能在不使用 ...
- Oracle用户角色权限相关视图
常用相关视图概述 DBA_SYS_PRIVS: 查询某个用户所拥有的系统权限 USER_SYS_PRIVS: 当前用户所拥有的系统权限 SESSION_PRIVS: 当前用户所拥有的全部权限 ROLE ...
- java课程设计全程实录——第2天
[反思] 今天主要完成JDBC数据的连接,查阅了大量博客和书籍,繁琐而细碎.但所幸还是连上了. [日常烦心事] 下午准备用idea连测试连接的,结果电脑跑不动....CPU一度100%居高不下,ide ...
- Java多线程——线程的创建方式
Java多线程——线程的创建方式 摘要:本文主要学习了线程的创建方式,线程的常用属性和方法,以及线程的几个基本状态. 部分内容来自以下博客: https://www.cnblogs.com/dolph ...
- iOS捷径(Workflow 2.0)拓展
前言 iOS12 捷径(Workflow 2.0)入门 iOS12 捷径(Workflow 2.0)进阶 iOS12捷径(Workflow 2.0)实例大全 注:本文主要介绍如何获取URL Schem ...
- BootStrap Select2组件
想使用Select2组件必须引用:select2.min.css和select2.min.js两个文件:如下: 页面写法很简单: 在这里多选是没有搜索功能的,只有单选的时候才会有搜索功能. Selec ...