题意:

  输入一个数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. Ubuntu install g++

    We can use two ways to  install g++ on Ubuntu. 1.  a. sudo apt-get install make gcc g++.      b. sud ...

  2. SQL知识整理一:触发器、存储过程、表变量、临时表

    触发器 触发器的基础知识 create trigger tr_name on table/view {for | after | instead of } [update][,][insert][,] ...

  3. Ubuntu 14.04下搜狗输入法崩溃重启

    pidof fcitx | xargs kill pidof sogou-qimpanel | xargs kill nohup fcitx >/dev/>/dev/null & ...

  4. lucene 索引 demo

    核心util /** * Alipay.com Inc. * Copyright (c) 2004-2015 All Rights Reserved/ */ package com.lucene.de ...

  5. Scrum Meeting 14-20151227

    说明 这几天我们代码人员一直在做数据库,没有来得及更新博客,从明天开始将会正常做scrum meeting,也将加快开发 工作,预计beta版本将会在12.30之前发布. 摘要 目前基本开发都已经做的 ...

  6. :target伪类制作tab选项卡

    :target伪类的作用是突出显示活动的HTML锚,下面是一个简单的例子: HTML代码: <div> <a href="#demo1">点击此处</ ...

  7. 常用SVN命令

    SVN命令 svn co  svn://10.144.156.41/branches/webroot_2015_03_03_gift 表示check远程目录到当前目录下,co命令只能check目录,如 ...

  8. Spring 配置解析之Properties

    http://www.cnblogs.com/dragonfei/archive/2016/10/09/5906474.html *********************************** ...

  9. Surface与SurfaceView、SurfaceHolder

    什么是Surface? android API的解释是:Handle onto a raw buffer that is being managed by the screen compositor ...

  10. 关于如何使用Identity的文献

    有几篇文件,深入浅出地讲解了如何一步一步的使用Identity,感觉十分有用,留下链接,备查. 1. Configuring Db Connection and Code-First Migratio ...