当前位置: 代码迷 >> 综合 >> HDOJ 1405 The Last Practice
  详细解决方案

HDOJ 1405 The Last Practice

热度:125   发布时间:2023-10-21 19:22:13.0

HDACM 1405

格式!!!
两行之间才有一空行
每行的格式 60: 2+” “+2 +” “+3 +” “+1+” “+ 5+” “+ 1+” “

import java.util.Scanner;public class Main{public static void main(String[] args) {Scanner sc = new Scanner(System.in);int i = 1;while (sc.hasNext()) {int n = sc.nextInt();if (n < 0) {break;}if (i!=1) {System.out.println();}System.out.println("Case "+i+".");int k = 2;int count = 0;while(n>1){if (n%k==0) {n /= k;count++;continue;}if (count>0) {System.out.print(k+" "+count+" ");}k++;count = 0;}System.out.println(k+" "+count+" ");i++;}sc.close();}
}