1001. Reverse Root

Time limit: 2.0 second
Memory limit: 64 MB

The problem is so easy, that the authors were lazy to write a statement for it!

Input

The input stream contains a set of integer numbers Ai (0 ≤ Ai ≤ 1018). The numbers are separated by any number of spaces and line breaks. A size of the input stream does not exceed 256 KB.

Output

For each number Ai from the last one till the first one you should output its square root. Each square root should be printed in a separate line with at least four digits after decimal point.

Sample

input

output

 1427  0   

 

   876652098643267843 

5276538

 

 

2297.0716

936297014.1164

0.0000

37.7757

 

 

代码:

using System;

using System.Globalization;

 

publicclassReverseRoot

{

privatestaticvoid Main()

    {

NumberFormatInfo nfi = NumberFormatInfo.InvariantInfo;

string[] input = Console.In.ReadToEnd().Split(

newchar[] { ' ''\t''\n''\r' }, StringSplitOptions.RemoveEmptyEntries);

for (int i = input.Length - 1; i >= 0; i--)

        {

double root = Math.Sqrt(double.Parse(input[i], nfi));

Console.WriteLine(string.Format(nfi, "{0:F4}", root));

        }

    }

}

 

总结:

1.学习了C#中的属性定义,并查找资料了解Console.In属性为什么还有方法ReadToEnd(),ReadToEnd()后面还有Split方法。

2.使用TextReader 类定义的输入方法ReadToEnd ( )String.Split( )方法 

3.了解NumberFormatInfo类及其成员

4.学习了输出格式

 

1.属性是一种类成员,它将字段和访问字段的方法组合在一起。属性不一定是值类型,它也可以是一个类的实例。所以说,属性是有类型的,这个类型有这个方法,就可以了!具体可参考http://bbs.csdn.net/topics/80284324http://zhidao.baidu.com/question/320769258.htmlReadToEnd()方法返回的是string对象,Split()方法是String类的方法,故可在ReadToEnd()后面还有Split方法。个人总结,是先执行Console.In.ReadToEnd(),再将返回的String对象Split(),这也是input是数组的原因.

 

2.方法:string ReadToEnd() TextReader类定义的输入方法,功能是读取数据流中从当前位置到结尾的所有字符并将它们作为一个字符串返回。String.Split()返回包含此实例中的子字符串(由指定 Char 或 String 数组的元素分隔)的 String 数组,详细可搜MSDN。

 

3.NumberFormatInfo类,根据区域性定义设置数值格式以及如何显示数值,详细可搜MSDN

 

4.学习了String.Format()方法格式化数据