集训第六周 数学概念与方法 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 ...
随机推荐
- Vue的响应式原理
Vue的响应式原理 一.响应式的底层实现 1.Vue与MVVM Vue是一个 MVVM框架,其各层的对应关系如下 View层:在Vue中是绑定dom对象的HTML ViewModel层:在Vue中是实 ...
- poj 1258 Agri-Net prim模板 prim与dijkstra的区别
很裸地求最小生成树的题目.题意就不多说了,最重要的就是记录一下学会了prim算法. 初学prim,给我的第一感觉就是和dijkstra好像啊,感觉两者的区别还是有的: 1:prim是求最小生成树的算法 ...
- POJ 2234 Nim博弈
思路: nim博弈裸题 xor一下 //By SiriusRen #include <cstdio> using namespace std; int n,tmp,xx; int main ...
- .NET通过字典给类赋值
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam& ...
- $.ajax json 在本地正常 上传服务器不正常
$.ajax( { url:"url",// 跳转到 action data:{name ...
- jQuery Ajax使用实例
<script src="http://cdn.bootcss.com/jquery/1.11.2/jquery.js"></script> <scr ...
- WAMP配置虚拟目录
1.启动wamp所有服务,输入localhost或localhost:端口号确保wamp环境正常无误. 2.设置httpd.conf 2.1打开文件:单击wamp在电脑右下角的图标=>wamp= ...
- AndroidStudio启动App时,数据取不到。
最近在用AndroidStudio开发App的时候,所连的服务器如果是换成本机上的,那么启动App的时候数据就读取不出来,连其它电脑上的服务器就是正常的,如下: 05-11 09:36:57.178 ...
- vue2.0 vue.extend()的拓展
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 分析HTTP 2.0与HTTP 1.1区别
1.什么是HTTP 2.0 HTTP/2(超文本传输协议第2版,最初命名为HTTP 2.0),是HTTP协议的的第二个主要版本,使用于万维网.HTTP/2是HTTP协议自1999年HTTP 1.1发布 ...