题目描述
求出区间[a,b]中所有整数的质因数分解。
输入格式
输入两个整数a,b。
提示
先筛出所有素数,然后再分解。
数据规模和约定
2<=a<=b<=10000
输出格式
每行输出一个数的分解,形如k=a1*a2*a3...(a1<=a2<=a3...,k也是从小到大的)(具体可看样例)
样例输入content_copy
3 10
样例输出content_copy
3=3
4=2*2
5=5
6=2*3
7=7
8=2*2*2
9=3*3
10=2*5
———————————————————————————————————————————#include<bits/stdc++.h>
using namespace std;
int main()
{
long long a=0,b=0,c=0,n=0;
cin>>a>>b;
for(int i=a;i<=b;i++)
{
int n=i;
cout<<i<<'=';
for(int j=2;j<=n;j++)
{
while(n%j==0)
{
cout<<j;
n=n/j;
if(n>1) cout<<'*';
}
}
cout<<endl;
}
return 0;
}