ˉ??????????????????????????????? ????????????????????????????????????°?? ???????????????????????г????????????????????????????4??6?????????£??????λ???????;???????????????????????????????????????????????????????????ü???????????4??6??????????424???????;????????????????????鵽????????????????????????????????????????????????д?????????? ????· ????????????A????B?????????A??B???檔 1???????30????????????,????????A??B???; 2????????????; 3??????????,??????3????,?????????B,??????????????????????????????,????????4??; 4?????????????鵽B??B???????????1??????鵽A??B????????????????B?ó?????????+1;???n?Σ?????????????A?鵽?????B,????????A?????Ч????????????????; ?????????,???n???100?????????????,????????????ζ??????д?????,???????????????ο???; A1B1 = 0.561 ???:???????????1??A??(??????????)??1??B??(???????),?????????A???????????Ч??????? A1B2 = 0.707 A1B3 = 0.780 A1B4 = 0.824 A2B2 = 0.643 A2B3 = 0.742 A2B4 = 0.798 A2B5 = 0.835 A2B6 = 0.861 ...... A1B29=0.971 ????????????,????1??A,??????????29??B,?????????????????????????????????ж?? ???????????ò?????A2B2??????????????????????????ALt+z??????????е?????????????±???; ?????????????A????????,???A???????Ч????4??6??,B??????????????,?????????A1B4????????,???A????Ч???B???????????????????; ?????·,????A????B?????????????????????,????????Ч??AB???????,??????????????????A??????,????A+B??,?????????????λ?????Ч????????????£? A1B1 = 0.28 A1B2 = 0.236 A1B3 = 0.195 A1B4 = 0.165 A1B5 = 0.142 A1B6 = 0.125 A2B1 = 0.248 A2B2 = 0.321 A2B3 = 0.297 A2B4 = 0.266 A2B5 = 0.239 A2B6 = 0.215 ???????????·???A2B2?????????! ????С?????????????????????????????????????????????? public class HS { public static void main(String[] args) { ArrayList list = new ArrayList(); for (int i = 0; i < 30; i++) { list.add("foo"); } int a=1; int b=29; for(int i=0;ilist.set(i, "A"); } for(int i=a;ilist.set(i, "B"); } int total=0; int max=1000000; for(int i=0;itotal = total+getCard(list, a, b); } System.out.println((double)total/max/a); } private static int getCard(ArrayList list, int a, int b) { Collections.shuffle(list); //System.out.println(list); int offensive=Math.random()<0.5?3:4; if(offensive==3) { //System.out.println("????"); } else { //System.out.println("????"); } for(int i=0;iString card=list.get(i); if("B".equals(card)) { Random random = new Random(); int n = random.nextInt(30-offensive)+offensive; String temp = list.get(n); list.set(n, "B"); list.set(i, temp); } } //System.out.println(list); int size=30; int get=0; int remain=b; int i=0; for(;iString card = list.get(i); if("foo".equals(card)) { //System.out.print(" foo:"+(i+1)); } else if("B".equals(card)) { remain=remain-1; //System.out.println(" B:"+(i+1)); } else if("A".equals(card)) { if(remain>0) { for(int ii=i;iiif("B".equals(list.get(ii))) { list.remove(ii); size=size-1; break; } } //System.out.println(" A+B:"+(i+1)); remain=remain-1; get=get+1; } } } for(int i1=0;i1list.add("B"); } //System.out.println("\n"+list); //System.out.println("get:"+get); return get; } ;i1++)>;ii++>;i++)>;i++)>;i++)>+b;i++)>;i++)>?????????????????
PS??????????????????????????????????????????? |