Skip to content

Commit

Permalink
Create zhaoyinwangluokeji.java
Browse files Browse the repository at this point in the history
  • Loading branch information
0xkookoo authored Sep 8, 2018
1 parent dacfa26 commit c5a0636
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/zhaoyinwangluokeji.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import java.util.Scanner;

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

int n = sc.nextInt();

Helper(n);
}

private static void Helper(int n) {
int count = 90;
int start = 1;
String res = "";
// System.out.print((count * 1.0 - (count-1)*count/2.0)/count);
while ((count * 1.0 - (count-1)*count/2.0)/count < start*1.0){
for (int i = 0; i <= n / count; i++) {
if (count * i + (count-1) * count /2.0 == n) {
System.out.print("[");
res += "[";
for (int j =i; j <= i+count-1; j++){
if (j==i+count-1){
System.out.println(j+"]");
res += Integer.toString(j) + "]";
break;
}
System.out.print(j+", ");
res += Integer.toString(j) + ", ";

}
// System.out.print("]");
// System.out.println("");
}
}
count -= 1;
}
res = new StringBuffer(res).reverse().toString();
// System.out.print(res);

}
}

0 comments on commit c5a0636

Please sign in to comment.