当前位置: 首页 > news >正文

1559 分解质因数

1559 分解质因数

⭐️难度:中等
🌟考点:唯一分解定理
📖
在这里插入图片描述

📚

import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        for (int i = a; i <= b ; i++) {
            System.out.print(i+"=");
            calc(i);
            System.out.println();
        }
    }

    static void calc(int x){
        boolean flag = false;
        for (int i = 2; i * i <= x ; i++) {
            while(x % i == 0){
                if(flag == true) System.out.print("*");
                flag = true;
                System.out.print(i);
                x /= i;
            }
        }
        if(x > 1){
            if(flag==true) System.out.print("*");
            System.out.print(x);
        }
    }
}

在这里插入图片描述

相关文章:

  • 使用Python从零开始构建生成型TransformerLM并训练
  • 高并发场景下的 Java 性能优化
  • 微信小程序开发:废品回收小程序-功能清单
  • react函数组件中,className字符串、style对象如何在父子组件之间传递
  • SpringBoot实战1
  • 基于元学习(Meta-Learning)的恶意流量检测
  • C++手撕单链表及逆序打印
  • 卫星互联网与数字样机:低轨星海竞速,谁主沉浮?
  • pytorch逻辑回归基本概念
  • 大模型之智能体
  • idea 创建 maven-scala项目
  • 《超短心法》速读笔记
  • 注意!4本期刊惨遭剔除,2025年首次EI目录迎来更新---附目录下载
  • QML自定义组件
  • opencv(C++)处理图像颜色
  • Spring事务系列 三
  • 项目合同从专家到小白
  • Java final关键字规范说明
  • Linux学习笔记——设备驱动
  • ‌UniApp 安卓打包完整步骤(小白向)