Acdream Training Tournament Series のjava session

Source: Internet
Author: User

/** This code was made by mhy12345* problem:1669* verdict:accepted* submission date:2015-04-21 13:39:02* time:140ms* MEMORY:23196KB*/ImportJava.util.*;Importjava.math.*;  Public classmain{Static  Public voidMain (String args[]) {Scanner in=NewScanner (system.in);  while(In.hasnext ()) {BigInteger n=In.nextbiginteger ();                        BigInteger L,r,mid; L=NewBigInteger ("0"); R=n.add (biginteger.valueof (1));  while(R.subtract (L). CompareTo (biginteger.valueof (1)) >0)                        {                                //System.out.println (L); //System.out.println (r);Mid= (R.add (L)). Divide (Biginteger.valueof (2)); if(Mid.multiply (mid). CompareTo (n) >0) {R=mid; }Else{L=mid; }} System.out.println (L.remainder (biginteger.valueof (2))); }        }}

B

/** This code was made by mhy12345* problem:1670* verdict:accepted* submission date:2015-04-21 15:01:14* time:172ms* MEMORY:27336KB*/ImportJava.util.*;Importjava.math.*;ImportJava.io.File;Importjava.io.IOException; Public classmain{Static  Public voidMain (String args[])throwsIOException {Scanner in=NewScanner (system.in); //Scanner in = new Scanner (New File ("Input.txt"));                 while(In.hasnext ()) {BigInteger n=In.nextbiginteger (); BigInteger x=NewBigInteger ("1");  for(inti=2;i<=10000000;i++)                        {                                Booleanflag=true;  for(intj=2;j<i;j++)                                {                                        if(i%j==0) {flag=false;  Break; }                                }                                if(!flag)Continue; if(X.multiply (biginteger.valueof (i)). CompareTo (n) >0)                                         Break; X=x.multiply (biginteger.valueof (i));                } System.out.println (X.tostring ()); }      

C

/** This code was made by mhy12345* problem:1668* verdict:accepted* submission date:2015-04-21 17:43:49* time:992ms* MEMORY:152756KB*/ImportJava.io.*;Importjava.math.*;ImportJava.util.*;  Public classmain{Static  Public voidMain (String args[])throwsIOException {Scanner in=NewScanner (system.in); intN;  while(In.hasnext ()) {n=In.nextint (); inta1,b1,a2,b2,a3,b3; A1=In.nextint (); B1=In.nextint (); A2=In.nextint (); B2=In.nextint (); A3=In.nextint (); B3=In.nextint (); BigDecimal v1=bigdecimal.valueof (A1). Divide (Bigdecimal.valueof (B1), 100, Bigdecimal.round_half_even); BigDecimal v2=bigdecimal.valueof (A2). Divide (bigdecimal.valueof (B2), 100, Bigdecimal.round_half_even); BigDecimal v3=bigdecimal.valueof (A3). Divide (Bigdecimal.valueof (B3), 100, Bigdecimal.round_half_even); BigDecimal dp[][]=Newbigdecimal[110][];  for(inti=0;i<110;i++) Dp[i]=Newbigdecimal[110];  for(inti=0;i<110;i++)                                 for(intj=0;j<110;j++) Dp[i][j]=NewBigDecimal ("0"); BigDecimal poss[][]=Newbigdecimal[110][];  for(inti=0;i<110;i++) Poss[i]=Newbigdecimal[110];  for(inti=0;i<110;i++)                                 for(intj=0;j<110;j++) Poss[i][j]=NewBigDecimal ("0"); Dp[n][n]=Bigdecimal.zero; Poss[n][n]=Bigdecimal.one; BigDecimal va=v1.add (V3.divide (bigdecimal.valueof (2), 100, Bigdecimal.round_half_even)); BigDecimal vb=v2.add (V3.divide (bigdecimal.valueof (2), 100, Bigdecimal.round_half_even));  for(inti=n;i>=1;i--)                        {                                 for(intj=n;j>=i;j--)                                {                                        if(J!=i && I!=1) {poss[i-1][j]=poss[i-1][j].add (Poss[i][j].multiply (v2)); Dp[i-1][j]=dp[i-1][j].add (Dp[i][j].add (poss[i][j]). Multiply (v2)); Poss[i][j-1]=poss[i][j-1].add (Poss[i][j].multiply (v3)); Dp[i][j-1]=dp[i][j-1].add (Dp[i][j].add (poss[i][j]). Multiply (v3)); Poss[i-1][j-1]=poss[i-1][j-1].add (poss[i][j].multiply (v1)); Dp[i-1][j-1]=dp[i-1][j-1].add (Dp[i][j].add (poss[i][j]). Multiply (v1)); //System.out.println (Poss[i][j-1] + "" + poss[i][j]);}Else if(I==1 && j!=i) {poss[i][j-1]=poss[i][j-1].add (Poss[i][j]); Dp[i][j-1]=dp[i][j-1].add (Dp[i][j].add (poss[i][j)); }Else if(J==i && I!=1) {poss[i-1][j-1]=poss[i-1][j-1].add (poss[i][j].multiply (VA)); Dp[i-1][j-1]=dp[i-1][j-1].add ((Dp[i][j].add (Poss[i][j])). Multiply (VA)); Poss[i-1][j]=poss[i-1][j].add (Poss[i][j].multiply (VB)); Dp[i-1][j]=dp[i-1][j].add ((Dp[i][j].add (Poss[i][j])). Multiply (VB)); }                                }                        }                        /*for (int i=1;i<=n;i++) {for (int j=1                                ; j<=n;j++) {System.out.print (dp[i][j]+ "");                        } System.out.println (); }                        */                    //System.out.println (dp[1][1]);System.out.println (Dp[1][1].setscale (50, Bigdecimal.round_half_even). toString ()); /*                        Double vv1,vv2,vv3;                        vv1= (double) a1/b1;                        Vv2= (double) a2/b2;                        vv3= (double) a3/b3;                        Double Dp[][]=new double[110][];                        for (int i=0;i<110;i++) dp[i]=new double[110];                        Double Poss[][]=new double[110][];                        for (int i=0;i<110;i++) poss[i]=new double[110];                        dp[n][n]=0;                        Poss[n][n]=1;                                for (int i=n;i>=1;i--) {for (int j=n;j>=i;j--)                                        {if (j!=i && i!=1)                                                {//system.out.println ("hehe" +i+ "" +j);   POSS[I-1][J]+=POSS[I][J]*VV2;                                             dp[i-1][j]+= (Dp[i][j]+poss[i][j]) *vv2;                                                Poss[i][j-1]+=poss[i][j]*vv3;                                                dp[i][j-1]+= (Dp[i][j]+poss[i][j]) *vv3;                                                POSS[I-1][J-1]+=POSS[I][J]*VV1;                                                dp[i-1][j-1]+= (Dp[i][j]+poss[i][j]) *vv1;                                        System.out.println (Poss[i][j-1] + "" + poss[i][j]); }else if (i==1 && j!=i) {PO                                                SS[I][J-1]+=POSS[I][J];                                        DP[I][J-1]+=DP[I][J]+POSS[I][J]; }else if (j==i && i!=1) {PO                       ss[i-1][j-1]+=poss[i][j]* (VV1+VV3/2);                         dp[i-1][j-1]+= (Dp[i][j]+poss[i][j]) * (VV1+VV3/2);                                                poss[i-1][j]+=poss[i][j]* (VV2+VV3/2);                                        dp[i-1][j]+= (Dp[i][j]+poss[i][j]) * (VV2+VV3/2);                        }}} for (int i=1;i<=n;i++)                                        {for (int j=1;j<=n;j++) {                                System.out.print (poss[i][j]+ "");                        } System.out.println ();                        } System.out.println (dp[1][1]);                         System.out.println (poss[1][1]);*/                }        }};

The remaining two questions are simply interesting ..... Don't write it.

Acdream Training Tournament Series のjava session

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.