就我一个是用二分搞的嘛?

P1035 [NOIP2002 普及组] 级数求和

SnowLove @ 2018-09-11 16:27:39

关键还特么错了 //package 实验; import java.math.BigInteger;

import java.util.Scanner; import java.util.; //import java.math.BigInteger; import java.io.;

public class Main { public static void main(String [] args){ Scanner cin = new Scanner(System.in); int k; k=cin.nextInt(); long l=0; long r=1000000000000L; long m=1; double c=0.5772156649;

   while(l<r){
       m=(l+r)/2;
       if(Math.log((double)(m))+c<=(double)k){
           l=m+1;
       } 
       else r=m-1; 
   }
   System.out.println(l);
}

}


|