【唯一分解定理】:https://www.cnblogs.com/mjtcn/p/6743624.html

假设x是一个正整数,它的值不超过65535(即1<x<=65535),请编写一个程序,将x分解为若干个素数的乘积。

Input

输入的第一行含一个正整数k (1<=k<=10),表示测试例的个数,后面紧接着k行,每行对应一个测试例,包含一个正整数x。

Output

每个测试例对应一行输出,输出x的素数乘积表示式,式中的素数从小到大排列,两个素数之间用“*”表示乘法。

Sample Input

2
11
9828

Sample Output

11
2*2*3*3*3*7*13 【代码】:
#include <iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<streambuf>
#include<cmath>
using namespace std;
#define ll long long
#define oo 10000000
int a[],k,n,t; int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
k=;
for(int i=;i<=n;i++)
{
while(n%i==)
{
a[k++]=i;
n/=i;
}
}
for(int i=;i<k;i++)
{
printf(i==?"%d":"*%d",a[i]);
}
printf("\n");
}
}

分解素因子

FZU 1075 分解素因子【数论/唯一分解定理/分解素因子裸模板】的更多相关文章

  1. AtCoder - 2286 (数论——唯一分解定理)

    题意 求n!的因子数%1e9+7. 思路 由唯一分解定理,一个数可以拆成素数幂之积,即2^a * 3^b *……,n!=2*3*……*n,所以计算每个素因子在这些数中出现的总次数(直接对2~n素因子分 ...

  2. HDU-1215 七夕节 数论 唯一分解定理 求约数之和

    题目链接:https://cn.vjudge.net/problem/HDU-1215 题意 中文题,自己去看吧,懒得写:) 思路 \[ Ans=\prod \sum p_i^j \] 唯一分解定理 ...

  3. UVA10791-Minimum Sum LCM(唯一分解定理基本应用)

    原题:https://vjudge.net/problem/UVA-10791 基本思路:1.借助唯一分解定理分解数据.2.求和输出 知识点:1.筛法得素数 2.唯一分解定理模板代码 3.数论分析-唯 ...

  4. codeforces C. Primes and Multiplication(快速幂 唯一分解定理)

    题目链接:http://codeforces.com/contest/1228/problem/C 题解:给定一个函数f,g,题目有描述其中的表达式含义和两者之间的关系. 然后计算: 首先把给定的x用 ...

  5. POJ1845Sumdiv(求所有因子和 + 唯一分解定理)

    Sumdiv Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 17387   Accepted: 4374 Descripti ...

  6. hdu3826-Squarefree number-(欧拉筛+唯一分解定理)

    Squarefree number Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  7. 简单数论之整除&质因数分解&唯一分解定理

    [整除] 若a被b整除,即a是b的倍数,那么记作b|a("|"是整除符号),读作"b整除a"或"a能被b整除".b叫做a的约数(或因数),a ...

  8. B - Common Divisors (codeforces)数论算法基本定理,唯一分解定理模板

    You are given an array aa consisting of nn integers. Your task is to say the number of such positive ...

  9. [CodeForces - 1225D]Power Products 【数论】 【分解质因数】

    [CodeForces - 1225D]Power Products [数论] [分解质因数] 标签:题解 codeforces题解 数论 题目描述 Time limit 2000 ms Memory ...

随机推荐

  1. Kali 中文家目录改英文目录

    中文版Kali装好之后,家目录会中文显示,不便操作 root@kali:~# ls -l drwxr-xr-x root root .0K 7月 : 公共 drwxr-xr-x root root . ...

  2. F#周报2019年第25期

    新闻 Azure Notebook概览 SpecFlow 3就在这里了! 使用新的Try .NET模版创建交互式文档 逐渐演化的.NET Core框架 Dylan与Linebreakers Oslo ...

  3. 【Word Break】cpp

    题目: Given a string s and a dictionary of words dict, determine if s can be segmented into a space-se ...

  4. leetcode 【 Search in Rotated Sorted Array 】python 实现

    题目: Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7  ...

  5. IOS开发学习笔记012-核心语法

    1.点语法 2.成员变量的作用域 3. @property和@synthesize 4.id类型 5.构造方法 6.自定义构造方法 7.模板修改 8.Category - 分类 9.类扩展 一.点语法 ...

  6. Anaconda的用法

    1. conda list -----显示anacoda安装的模块 2.jupyter notebook----启动网页上的python编程环境 3.anacoda  search -t conda ...

  7. docker exec小脚本

    经常要使用docker exec -it containerID bash 进入docker内部进行一些操作,干脆把它写成shell脚本节省时间. # 查看需要操作的容器id $ docker ps ...

  8. poj3748 位运算 bitset

    位操作 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9064   Accepted: 3626 Description 假 ...

  9. redis.clients.jedis.exceptions.JedisDataException: MISCONF Redis is configured to save RDB snapshots

    最近在学习Redis ,在写test测试的时候碰到这个报错: redis.clients.jedis.exceptions.JedisDataException: MISCONF Redis is c ...

  10. TypeError: $.ajaxFileUpload(…) is not a function

    今天做一个图片上传功能,用到了ajaxFileUpload,控制台报错TypeError: $.ajaxFileUpload(…) is not a function,都说是jQuery版本问题,也试 ...