标签:ali tin util style mat tput stat tle asn
Description |
同题目E |
Input |
N |
Output |
complete numbers within 2~N |
Sample Input |
10 100 |
Sample Output |
6=1+2+3 6=1+2+3 28=1+2+4+7+14
|
1 import java.util.*; 2 public class Main{ 3 public static void main(String[] args){ 4 Scanner in = new Scanner(System.in); 5 while(in.hasNext()){ 6 int num = in.nextInt(); 7 for(int i=6;i<=num;i++){ 8 int sum = 0; 9 int[] arr = new int[100]; 10 int k = 0; 11 for(int j=1;j<i;j++) 12 if(i%j==0){ 13 sum += j; 14 arr[k++] = j; 15 } 16 if(sum==i){ 17 System.out.print(i+"="); 18 for(int l=0;l<k;l++){ 19 System.out.print(arr[l]); 20 if(l!=k-1) 21 System.out.print("+"); 22 } 23 System.out.println(); 24 } 25 } 26 } 27 } 28 }
标签:ali tin util style mat tput stat tle asn
原文地址:https://www.cnblogs.com/1Kasshole/p/9007371.html