hdoj 1405 The Last Practice
The Last Practice
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 9037 Accepted Submission(s): 1905
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.
60=2^2*3^1*5^1
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<math.h>
#define MAX 1100
using namespace std;
int a[MAX],b[MAX];
int main()
{
int k,n,m,j,i;
k=1;
while(scanf("%d",&n)&&n>=0)
{
if(k>1)
printf("\n");
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
printf("Case %d.\n",k++);
m=n;j=0;
for(i=2;i<=n;i++)
{
int sum=0;
if(m%i==0)
{
while(m%i==0)
{
m/=i;
sum++;
}
a[j]=i;
b[j++]=sum;
}
if(m==1)
break;
}
for(i=0;i<j;i++)
printf("%d %d ",a[i],b[i]);
printf("\n");
}
return 0;
}
hdoj 1405 The Last Practice的更多相关文章
- HDU 1405 The Last Practice
The Last Practice Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- HDU 1405 The Last Practice 数学水题
http://acm.hdu.edu.cn/showproblem.php?pid=1405 题目大意: 给你一个数,让你分解素因子,输出它的各次幂. 如60 输出:2 2 3 1 5 1 (60=2 ...
- Pramp mock interview (4th practice): Matrix Spiral Print
March 16, 2016 Problem statement:Given a 2D array (matrix) named M, print all items of M in a spiral ...
- Atitit 数据存储视图的最佳实际best practice attilax总结
Atitit 数据存储视图的最佳实际best practice attilax总结 1.1. 视图优点:可读性的提升1 1.2. 结论 本着可读性优先于性能的原则,面向人类编程优先于面向机器编程,应 ...
- HDOJ 1009. Fat Mouse' Trade 贪心 结构体排序
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- HDOJ 1326. Box of Bricks 纯水题
Box of Bricks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
- The Practice of .NET Cross-Platforms
0x01 Preface This post is mainly to share the technologies on my practice about the .NET Cross-Platf ...
- HDOJ 1004 Let the Balloon Rise
Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...
随机推荐
- linux samba.tar.gz安装和配置
安装步骤: 1. tar -xzvf samba-3.5.10.tar.gz2. cd samba-3.5.103. cd source34. ./autogen.sh 如果出现:./autogen ...
- mac 用 brew
mac 下用 brew 安装插件, 有重复的不会再次安装,比xmap模式好
- python之高性能网络编程并发框架eventlet实例
http://blog.csdn.net/mingzznet/article/details/38388299 前言: 虽然 eventlet 封装成了非常类似标准线程库的形式,但线程和eventle ...
- C#基础精华04(文件流,文件操作,File、Directory、Path,Directory)
文件流 FileStream 可读可写 大文件 释放 StreamReader 读取 释放 StreamWriter 写入 释放 using 中释放 File 可读可写 小文件 操作文 ...
- ENVI5.1安装破解教程
原文地址: ENVI5.1安装破解_百度经验 http://jingyan.baidu.com/article/020278118b5ded1bcd9ce57a.html ENVI5.1_x86 ...
- centos更新163源并升级内核
使用说明 首先备份/etc/yum.repos.d/CentOS-Base.repo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/Cen ...
- C中如何调用C++函数、类内函数 \混编\链接
在C中如何调用C++函数的问题,简单回答是将函数用extern "C"声明,当被问及如何将类内成员函数声明时,一时语塞,后来网上查了下,网上有一翻译C++之父的文章可以作为解答,遂 ...
- Creating a web server in pure C(c/c++ 写web server)
一个简单的例子:https://github.com/fekberg/GoHttp 一个运行在windows上例子:http://www.adp-gmbh.ch/win/misc/webserver. ...
- 超实用的PHP代码片段
一.查看邮件是否已被阅读 当你在发送邮件时,你或许很想知道该邮件是否被对方已阅读.这里有段非常有趣的代码片段能够显示对方IP地址记录阅读的实际日期和时间. 1 2 3 4 5 6 7 8 9 10 1 ...
- 存储过程 务的概念 事务的特性 关于异常的处理 连接池 构JdbcUtil类
1 存储过程 1)用当地数据库语言,写的一段业务逻辑算法,并该算法存储在客户端 2)使用存储过程需要用于CallableStatement接口,同时需要使如下SQL命令调用:{call a ...