import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
String m = "";
StringBuffer sb = new StringBuffer("");
while (true) {
int n = Integer.parseInt(br.readLine());
if (n == 0) {
break;
}
boolean neg = false;
double lol = Math.log(n);
int c = (int) Math.floor(lol);
lol = 1.0 - n / Math.pow(Math.E, 1.0 * c);
if (Math.abs(lol) > 1) {
c++;
lol = 1.0 - n / Math.pow(Math.E, 1.0 * c);
}
if (lol < 0) {
neg = true;
}
String g = (int) (Math.round(Math.abs(lol) * 1000 * 1000 * 100)) + "";
sb.append(c).append(" ");
if (neg) {
sb.append("-");
}
sb.append("0.");
for (int i = g.length(); i < 8; i++) {
sb.append('0');
}
sb.append(g).append("\n");
}
System.out.print(sb);
}
}
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
String m = "";
StringBuffer sb = new StringBuffer("");
while (true) {
int n = Integer.parseInt(br.readLine());
if (n == 0) {
break;
}
boolean neg = false;
double lol = Math.log(n);
int c = (int) Math.floor(lol);
lol = 1.0 - n / Math.pow(Math.E, 1.0 * c);
if (Math.abs(lol) > 1) {
c++;
lol = 1.0 - n / Math.pow(Math.E, 1.0 * c);
}
if (lol < 0) {
neg = true;
}
String g = (int) (Math.round(Math.abs(lol) * 1000 * 1000 * 100)) + "";
sb.append(c).append(" ");
if (neg) {
sb.append("-");
}
sb.append("0.");
for (int i = g.length(); i < 8; i++) {
sb.append('0');
}
sb.append(g).append("\n");
}
System.out.print(sb);
}
}
No comments:
Post a Comment