rookie


私信TA

用户名:rookie

访问量:3243

签 名:

等  级
排  名 11946
经  验 948
参赛次数 1
文章发表 4
年  龄 0
在职情况 学生
学  校 武汉生物工程学院
专  业 软件工程

  自我简介:

出门一条C艹,AC基本靠捡

解题思路:
埃式 筛选出素数表,分解质因数 是一个合数分解出来的因素满足素数条件,被称为分解质因数,依次打印即可


注意事项:

参考代码:

#include <bits/stdc++.h>
/**
@author:d g w
*/
using namespace std;

#define N 10000

int t[10000];
int main()
{
    int a,b;
    fill(t,t+N,1);
    t[0]=t[1]=0;
    for(int i=2;i<N;i++){
        if(t[i]){
            for(int j=2*i;j<N;j+=i){
                t[j]=0;
            }
        }
    }
    cin>>a>>b;
    for(int i=a;i<=b;i++){
        int temp=i;

        int flag=0;
        cout<< i <<"=";
        while(temp!=1){
            for(int j=2;j<=temp;j++){
                if(temp%j==0&&t[j]){
                    temp/=j;
                     if(flag==1){
                        cout<<"*";
                     }
                     cout<<j;
                     flag=1;
                     break;
                }
            }

        }
        cout<<endl;
    }
    return 0;
}


 

0.0分

2 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区