题目链接

题意 : 给你一个数,让你用它的素数质因子表示出来。

思路 : 先打一下表,因为会有重复的质因子,所以从大到小开始找,并且找到一个之后不能就接着往下找,要再找一遍这个数。

 #include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream> using namespace std ; int IsPrime[] ; void sett()
{
int i,j;
for(i = ; i <= ; ++i)
IsPrime[i] = true;
IsPrime[] = IsPrime[] = false ;
for(i = ; i <= ; ++i)
{
if(IsPrime[i])
{
for(j = *i ; j <= ; j += i)
IsPrime[j]=false;
}
}
}
int main()
{
int n ;
int a[] ;
sett() ;
while(scanf("%d",&n)!= EOF)
{
int cnt = ;
for(int i = ; i > ; i--)
{
if(n%i == && IsPrime[i])
{
a[cnt++] = i ;
n /= i ;
i++ ;
}
}
printf("%d",a[cnt-]) ;
for(int i = cnt- ; i >= ; i--)
{
printf("*%d",a[i]) ;
}
printf("\n") ;
}
return ;
}

HDU 1164 Eddy's research I的更多相关文章

  1. hdu 1164:Eddy's research I(水题,数学题,筛法)

    Eddy's research I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  2. hdu 1164 Eddy's research I

    http://acm.hdu.edu.cn/showproblem.php?pid=1164 题意很简单,只是写代码的时候需要注意几个问题 一.筛选素数的时候记得用埃式筛选法,要是直接找可能会WA. ...

  3. HDU 1164 Eddy's research I( 试除法 & 筛法改造试除法 分解整数 )

    链接:传送门 题意:给出一个整数 n ,输出整数 n 的分解成若干个素因子的方案 思路:经典的整数分解题目,这里采用试除法 和 用筛法改造后的试除法 对正整数 n 进行分解 方法一:试除法对正整数 n ...

  4. HDU 1164 Eddy&#39;s research I【素数筛选法】

    思路:将输入的这个数分成n个素数的相乘的结果,用一个数组存储起来.之后再输出就能够了 Eddy's research I Time Limit: 2000/1000 MS (Java/Others)  ...

  5. HDU 1165 Eddy's research II(给出递归公式,然后找规律)

    - Eddy's research II Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64 ...

  6. HDOJ 1164 Eddy's research I(拆分成素数因子)

    Problem Description Eddy's interest is very extensive, recently he is interested in prime number. Ed ...

  7. HDOJ 1164 Eddy's research I

    Problem Description Eddy's interest is very extensive, recently he is interested in prime number. Ed ...

  8. HDU 1165 Eddy's research II (找规律)

    题意:给定一个表达式,然后让你求表达式的值. 析:多写几个就会发现规律. 代码如下: #pragma comment(linker, "/STACK:1024000000,102400000 ...

  9. HDU 1165 Eddy's research II

    题意:已知,求A(m, n). 分析:根据样例模拟一下过程就可以找出递推关系. #include<cstdio> #include<cstring> #include<c ...

随机推荐

  1. <Linux下FTP服务的搭建>

    默认安装好ftp软件包匿名用户是可以下载的.匿名以后可以上传:anon_upload_enable=YES# getsebool -a | grep ftpallow_ftpd_anon_write ...

  2. linux terminal 日常shell

    1 ubuntu中如何将终端添加到右键 /home/cui/.local/share/nautilus/scripts #!/bin/bash #cd $NAUTILUS_SCRIPT_CURRENT ...

  3. 【Qt】Qt Creator介绍【转】

    简介 Qt Creator是使用Qt开发的IDE.Qt支持Windows.Linux/Unix.Mac OS X.Android.BlackBerry.QNX等多种平台,Qt Creator为不同平台 ...

  4. CentOS 7 终端设置屏幕分辨率

    在grub中我们修改的是/boot/grub/grub.conf,而在grub2中要修改的文件是/boot/grub2/grub.cfg inux16 /vmlinuz-3.10.0-123.el7. ...

  5. SOA Demo

    使用SOA来实现两个数字的相加,不包含验证,仅供练习使用. PDF文档下载地址:http://files.cnblogs.com/chenyongblog/SOA_Demo.pdf 源码下载:http ...

  6. VS2010性能监视工具

    <编程珠玑(续)>第一章中就介绍了性能监视工具,对于较简单的程序来说,性能监视工具其实可以用变量累加来计算的,但是对于较复杂的程序来说就需要比较好的性能监视工具了.而VS2010提供了一个 ...

  7. iOS开发中GCD在多线程方面的理解

    GCD为Grand Central Dispatch的缩写. Grand Central Dispatch (GCD)是Apple开发的一个多核编程的较新的解决方法.在Mac OS X 10.6雪豹中 ...

  8. 在Web API中使用Swagger-UI开源组件(一个深坑的解决)

    介绍: Swagger-Ui是一个非常棒的Web API说明帮助页,具体详情可自行Google和百度. 官网:http://swagger.io/    GitHub地址:https://github ...

  9. JDBC 学习笔记(二)—— 大数据+存储过程+批处理+事务管理

    本文目录:       1.使用JDBC处理大数据        2.使用JDBC处理大文本        3.使用JDBC处理二进制数据        4.Oracle中大数据处理        5 ...

  10. android 开发:讯飞的离线命令识别器官方demo使用及demo下载

    场景:使用本地构建语法,离线识别命令词. 修改文件AsrDemo.java mLocalGrammar  修改为你自己的语法 mAsr.setParameter(SpeechConstant.GRAM ...