题意:

  输入一个数n,输出它的素因子与这个素因子出现的次数.

分析:

  用欧拉函数,变下形就好了,不再过多解释.

代码如下:

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <ctime>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <iterator>
#include <vector> using namespace std; #define LL long long
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define MAXN 10000010
#define MAXM 1000010 const int maxn = ;
int a[maxn]; void euler_phi(int n)
{
int m = (int)sqrt(n+0.5);
//int ans = n;
for(int i = ; i <= m; i++ )
if(n%i==)
{
//ans = ans/i*(i-1);
while(n%i==)
{
a[i]++;
n /= i;
}
}
if(n > )
a[n]++;
// ans = ans/n*(n-1);
// return ans;
} int main()
{
int n;
int kase = ;
while(scanf("%d", &n)==&&n>=)
{
if(kase)
printf("\n");
memset(a, , sizeof(a));
euler_phi(n);
printf("Case %d.\n", ++kase);
for(int i = ; i <= n; i++ )
if(a[i])
printf("%d %d ", i, a[i]);
printf("\n");
} return ;
}

HDU 1405的更多相关文章

  1. HDU 1405 The Last Practice 数学水题

    http://acm.hdu.edu.cn/showproblem.php?pid=1405 题目大意: 给你一个数,让你分解素因子,输出它的各次幂. 如60 输出:2 2 3 1 5 1 (60=2 ...

  2. HDU 1405 第六周 J题

    Description Tomorrow is contest day, Are you all ready?  We have been training for 45 days, and all ...

  3. HDU 1405 The Last Practice

    The Last Practice Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  4. HDU——PKU题目分类

    HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...

  5. [转] HDU 题目分类

    转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008 ...

  6. HDU ACM 题目分类

    模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 104 ...

  7. HDU 5643 King's Game 打表

    King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...

  8. 转载:hdu 题目分类 (侵删)

    转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...

  9. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

随机推荐

  1. html 上传预览图片

    直接上代码了 <!DOCTYPE html> <html><head lang="en"><meta http-equiv="C ...

  2. servlet获取表单数据的方式和编码方式

    .在servlet中获取表单的数据的几种方式  1>request.getParameter(“name”)://获取指定名称的值,返回值类型是一个字符串  2>request.getPa ...

  3. 在Eclipse中添加C/C++插件

    如果尚未安装 Eclipse,可直接下载包含C/C++的 Eclipse IDE http://www.eclipse.org/downloads/eclipse-packages/?osType=l ...

  4. duilib的caption上的Edit无法激活

    当窗口设置标题栏时,鼠标等控件可以相应,edit无法响应. 主要和WindowImplBase::OnNcHitTest 虚函数有关. LRESULT WindowImplBase::OnNcHitT ...

  5. You Don't Know JS: Scope & Closures(翻译)

    Chapter 1: What is Scope? 第一章:什么是作用域 One of the most fundamental paradigms of nearly all programming ...

  6. 磁盘文件系统Fat、Fat32、NTFS、exFAT的优缺点

    我们在Windows系统里格式化磁盘的时候,文件系统的选项里可以看到有“FAT”.“FAT32”.“NTFS”等选项,在对U盘或其他移动存储设备 格式化的时候还会出现“exFAT”选项,那么这四种磁盘 ...

  7. AR/VR技术交流

    本人建了一个QQ群(群号:331922761),欢迎对AR,VR技术感兴趣的同学加入一起学习讨论.

  8. 反斜杠在JSP中的两种不同的含义

    / 在不同条件下的不同含义 / 代表WEB应用的根路径的情况:/ 交给 Servlet容器来处理 请求转发时: request.getRequestDispatcher("/xxxx&quo ...

  9. Oracle 11g default profile 默认启用密码过期180天 ORA-28001错误处理

    问题描述:客户反映客户端不能登录应用程序时不能连接.环境:AIX 5.3 + Oracle 11gR2解决:远程Telnet到数据库主机,sqlplus / as sysdba 连接后操作正常,表明数 ...

  10. winform项目打包成可安装程序(vs2015)

    1.新建安装和部署项目      如果是初始使用并且原来没有下载过,会被所引导一个下载界面http://learn.flexerasoftware.com/content/IS-EVAL-Instal ...