俄罗斯乌拉尔大学在线题库
是一个可以使用C#语言的在线ACM题库,有兴趣的朋友可以去试试。
Problem 1000. A+B Problem 是入门,就是简单地求整数 A 和 B 的和就行了,答案如下:
Problem 1001. Reverse root 也很简单,就是给出一组整数,然后反序输出其平方根就行了,答案如下:
注意该程序的第11行不可省略,不然就无法通过。目前还不知道是什么原因( 已经找到原因了,请参见2楼的评论 )。
Problem 1005. Stone pile 要求将若干石头分为两堆使其重量差最小,答案如下:
Problem 1000. A+B Problem 是入门,就是简单地求整数 A 和 B 的和就行了,答案如下:
1
using
System;
2
3 // http://acm.timus.ru/problem.aspx?space=1 &num=1000
4 class Acm1000
5 {
6 static void Main()
7 {
8 string [] ss = Console.ReadLine().Split();
9 Console.WriteLine( long .Parse(ss[ 0 ]) + long .Parse(ss[ 1 ]));
10 }
11 }
12
2
3 // http://acm.timus.ru/problem.aspx?space=1 &num=1000
4 class Acm1000
5 {
6 static void Main()
7 {
8 string [] ss = Console.ReadLine().Split();
9 Console.WriteLine( long .Parse(ss[ 0 ]) + long .Parse(ss[ 1 ]));
10 }
11 }
12
Problem 1001. Reverse root 也很简单,就是给出一组整数,然后反序输出其平方根就行了,答案如下:
1
using
System;
2 using System.Threading;
3 using System.Globalization;
4 using System.Text.RegularExpressions;
5
6 // http://acm.timus.ru/problem.aspx?space=1 &num=1001
7 class Acm1001
8 {
9 static void Main()
10 {
11 Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
12 string [] nums = Regex.Split(Console.In.ReadToEnd().Trim(), @" \s+ " );
13 for ( int i = nums.Length - 1 ; i >= 0 ; i -- )
14 Console.WriteLine( " {0:F4} " , Math.Sqrt( ulong .Parse(nums[i])));
15 }
16 }
17
2 using System.Threading;
3 using System.Globalization;
4 using System.Text.RegularExpressions;
5
6 // http://acm.timus.ru/problem.aspx?space=1 &num=1001
7 class Acm1001
8 {
9 static void Main()
10 {
11 Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
12 string [] nums = Regex.Split(Console.In.ReadToEnd().Trim(), @" \s+ " );
13 for ( int i = nums.Length - 1 ; i >= 0 ; i -- )
14 Console.WriteLine( " {0:F4} " , Math.Sqrt( ulong .Parse(nums[i])));
15 }
16 }
17
注意该程序的第11行不可省略,不然就无法通过。目前还不知道是什么原因( 已经找到原因了,请参见2楼的评论 )。
Problem 1005. Stone pile 要求将若干石头分为两堆使其重量差最小,答案如下:
1
using
System;
2 using System.IO;
3 using System.Text.RegularExpressions;
4
5 // http://acm.timus.ru/problem.aspx?space=1 &num=1005
6 class Acm1005
7 {
8 static void Main()
9 {
10 new Acm1005().Run(Console.In, Console.Out);
11 }
12
13 void Run(TextReader reader, TextWriter writer)
14 {
15 writer.WriteLine(GetResult(GetWeigths(reader)));
16 }
17
18 int [] GetWeigths(TextReader reader)
19 {
20 string [] ss = Regex.Split(reader.ReadToEnd().Trim(), @" \s+ " );
21 int [] weigths = new int [ int .Parse(ss[ 0 ])];
22 for ( int i = 0 ; i < weigths.Length; i ++ ) weigths[i] = int .Parse(ss[i + 1 ]);
2 using System.IO;
3 using System.Text.RegularExpressions;
4
5 // http://acm.timus.ru/problem.aspx?space=1 &num=1005
6 class Acm1005
7 {
8 static void Main()
9 {
10 new Acm1005().Run(Console.In, Console.Out);
11 }
12
13 void Run(TextReader reader, TextWriter writer)
14 {
15 writer.WriteLine(GetResult(GetWeigths(reader)));
16 }
17
18 int [] GetWeigths(TextReader reader)
19 {
20 string [] ss = Regex.Split(reader.ReadToEnd().Trim(), @" \s+ " );
21 int [] weigths = new int [ int .Parse(ss[ 0 ])];
22 for ( int i = 0 ; i < weigths.Length; i ++ ) weigths[i] = int .Parse(ss[i + 1 ]);