using System;
public class Test
{
public static void Main()
{
Console.WriteLine(Normalized(305));
Console.WriteLine(Normalized(-305));
Console.WriteLine(Normalized(0.0305));
Console.WriteLine(Normalized(-0.0305));
Console.WriteLine(Normalized(0.0));
}
public static string Normalized(double num)
{
var ord = Ord(num);
var mant = num / Math.Pow(10, ord);
return string.Format("{0} * 10^{1}", mant, ord);
}
public static int Ord(double num)
{
if(num == 0.0) { return 0; }
return (int)Math.Floor(Math.Log10(Math.Abs(num)));
}
}
dXNpbmcgU3lzdGVtOwoKcHVibGljIGNsYXNzIFRlc3QKewoJcHVibGljIHN0YXRpYyB2b2lkIE1haW4oKQoJewogICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKE5vcm1hbGl6ZWQoMzA1KSk7CiAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoTm9ybWFsaXplZCgtMzA1KSk7CiAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoTm9ybWFsaXplZCgwLjAzMDUpKTsKICAgICAgICBDb25zb2xlLldyaXRlTGluZShOb3JtYWxpemVkKC0wLjAzMDUpKTsKICAgICAgICBDb25zb2xlLldyaXRlTGluZShOb3JtYWxpemVkKDAuMCkpOwoJfQoJCglwdWJsaWMgc3RhdGljIHN0cmluZyBOb3JtYWxpemVkKGRvdWJsZSBudW0pCgl7CiAgICAgICAgdmFyIG9yZCA9IE9yZChudW0pOwogICAgICAgIHZhciBtYW50ID0gbnVtIC8gTWF0aC5Qb3coMTAsIG9yZCk7CgkJcmV0dXJuIHN0cmluZy5Gb3JtYXQoInswfSAqIDEwXnsxfSIsIG1hbnQsIG9yZCk7Cgl9CgkKCXB1YmxpYyBzdGF0aWMgaW50IE9yZChkb3VibGUgbnVtKQoJewoJCWlmKG51bSA9PSAwLjApIHsgcmV0dXJuIDA7IH0KCQlyZXR1cm4gKGludClNYXRoLkZsb29yKE1hdGguTG9nMTAoTWF0aC5BYnMobnVtKSkpOwoJfQp9