java AC in the top of ranks
Posted by
esbybb 21 Jul 2015 11:37
InputStream is = System.in;
byte[]b = new byte[1000_001];
int L = is.read(b)-1;
while(b[L]<48 || b[L]>57) L--;
int i=0;
double D = Math.sqrt(0.5);
double x=0;
double y=0; // 1 2 3 4 5 6 7 8 9
double[] shftx = new double[]{0,-D, 0, D,-1, 0, 1,-D, 0, D};
double[] shfty = new double[]{0,-D,-1,-D, 0, 0, 0, D, 1, D};
while(i<=L && b[i]!=48 && b[i]!=0){
x+=shftx[b[i]-48];
y+=shfty[b[i]-48];
i++;
}
System.out.println(String.format("%.10f %.10f", x, y));