Last active
August 29, 2015 14:07
-
-
Save nomuken/998d24857c8963622114 to your computer and use it in GitHub Desktop.
頑張った(typoは気にしない主義)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.math.BigDecimal; | |
import java.math.MathContext; | |
import java.util.ArrayList; | |
public class Tes{ | |
public static void main(String[] args){ | |
int error = 18; | |
BigDecimal powAns = new BigDecimal(123); | |
BigDecimal ans = new BigDecimal("0"); | |
ArrayList<Double> range = new ArrayList<Double>(); | |
for(int i=1;error>=i;i++){ | |
range.add(new Double(mutiString(i))); | |
} | |
for(Double stp : range) { | |
BigDecimal rng = new BigDecimal(stp.doubleValue()); | |
for (; 1 > ans.multiply(powAns, MathContext.DECIMAL128).doubleValue(); ans = ans.add(rng)); | |
ans = ans.subtract(rng); | |
} | |
ans=ans.add(new BigDecimal(range.get(range.size()-1))); | |
System.out.println(ans.doubleValue()); | |
} | |
public static String mutiString(int n){ | |
String ans = "0."; | |
for(int i=0;n-1>i;i++)ans+="0"; | |
ans+="1"; | |
return ans; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment