fork download
  1. import java.util.*;
  2. class M{
  3. static String c(int a, int b, int c, int d){
  4. String r = "",
  5. w = "",
  6. l = "";
  7. List z = new ArrayList();
  8. int i,
  9. q = a+b-c-d;
  10. for(i = 0; i++ < c; w += 1);
  11. for(i = 0; i++ < d; l += 0);
  12. for( ; a-- - c > 0; z.add(1));
  13. for( ; b-- - d > 0; z.add(0));
  14. Collections.shuffle(z);
  15. for(i = 0; i < q; r += z.get(i++));
  16. return new StringBuilder(r).insert(new Random().nextInt(q), w+l)+"";
  17. }
  18.  
  19. public static void main(String[] a){
  20. System.out.println(c(7, 3, 5, 2));
  21. System.out.println(c(171, 111, 10, 4));
  22. }
  23. }
Success #stdin #stdout 0.05s 711168KB
stdin
Standard input is empty
stdout
1011111001
001111101110111101111110110011110010111101010101111001111110011000110111111001111100010001011001110010111110110111111111111000010010100101010100001000111000111001010001111001111010101011110111110110110111000110110110101010111111110000110100110001111111010001100001111111101011000001