You can use the online ACM library in C # language.

The online Q & A library of Russian uural University is an online ACM library that can use C # language. If you are interested, try it.

Problem 1000. A + B Problem is an entry, that is, simply calculate the sum of integers A and B. The answer is as follows:

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

Problem 1001. Reverse root is also very simple, that is, to give a group of integers, and then output its square root in Reverse order. The answer is as follows:

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

Note that line 1 of the program cannot be omitted, otherwise it will fail. I still don't know why. (The reason has been found. Please refer to the comments on the second floor ).

Problem 1005. Stone pile requires that several stones be divided into two heaps to minimize the weight difference. The answer is as follows:

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]);

23 return weigths;

24}

25

26 int GetResult (int [] weigths)

27 {

28 int n = weigths. Length-1;

29 int result = int. MaxValue;

30 int [] piles = new int [2];

31 for (int I = (1 <n)-1; I> = 0; I --)

32 {

33 piles [0] = weigths [n];

34 piles [1] = 0;

35 for (int j = n-1; j> = 0; j --) piles [(I> j) & 1) = 0 )? 1: 0] + = weigths [j];

36 int v = Math. Abs (piles [0]-piles [1]);

37 if (result> v) result = v;

38}

39 return result;

40}

41}

42

Problem 1068. Sum is also very simple, that is, the Sum of 1 to N. The answer is as follows:

1 using System;

2

3 //__Http://acm.timus.ru/problem.aspx? Space = 1__& Num = 1068

4 class Acm1068

5 {

6 static void Main ()

7 {

8 Console. WriteLine (Sum (int. Parse (Console. ReadLine ())));

9}

10

11 static long Sum (long n)

12 {

13 if (n> 0) return n * (n + 1)/2;

14 if (n <0) return 1 + n * (1-n)/2;

15 return 1;

16}

17}

18

Problem 1070. A local time is required to calculate the time difference between the two places based on the time (expressed by the local time) of the round-trip flight between the two places. The answer is as follows:

1 using System;

2 using System. IO;

3

4 //__Http://acm.timus.ru/problem.aspx? Space = 1__& Num = 1070

5 class Acm1070

6 {

7 static void Main ()

8 {

9 new Acm1070 (). Run (Console. In, Console. Out );

10}

11

12 void Run (TextReader reader, TextWriter writer)

13 {

14 double diff1 = GetDuration (reader );

15 double diff2 = GetDuration (reader );

16 writer. WriteLine (Math. Abs (int) Math. Round (diff1-diff2)/2 )));

17}

18

19 double GetDuration (TextReader reader)

20 {

21 string [] ss = reader. ReadLine (). Split ();

22 double diff = (GetTime (ss [1])-GetTime (ss [0]). TotalHours;

23 if (diff> 6) diff-= 24;

24 if (diff <-6) diff + = 24;

25 return diff;

26}

27

28 DateTime GetTime (string s)

29 {

30 string [] ss = s. Split ('.');

31 return new DateTime (1, 1, 1, int. Parse (ss [0]), int. Parse (ss [1]), 0 );

32}

33}

34

Other questions may not be so easy. :)

According to comments from Friends of CppGohan on the eighth floor, Sphere Onlile Judge (SPOJ) is also an online ACM library that supports C # languages.

1. Life, the Universe, and Everything is an entry, that is, copying the standard input as is to the standard output in one row until a row is "42". the answer is as follows:

1 using System;

2 using System. IO;

3

4 //

__Http://www.spoj.pl/problems/TEST/__
5 class S1

6 {

7 static void Main ()

8 {

9 new S1 (). Run (Console. In, Console. Out );

10}

11

12 void Run (TextReader reader, TextWriter writer)

13 {

14 (;;)

15 {

16 string s = reader. ReadLine ();

17 if (s = null) break;

18 if (s = 42) break;

19 writer. WriteLine (s );

20}

21}

22}

23

2. Prime Generator requires that multiple groups of Prime numbers in the specified range be generated. The answer is as follows:

1 using System;

2 using System. IO;

3

4 //

__Http://www.spoj.pl/problems/PRIME1/__
5 class S2

6 {

7 struct Range

8 {

9 public int Min;

10 public int Max;

11}

12

13 static void Main ()

14 {

15 new S2 (). Run (Console. In, Console. Out );

16}

17

18 void Run (TextReader reader, TextWriter writer)

19 {

20 int theMax;

21 Range [] ranges = GetRanges (reader, out theMax );

22 int min = 3;

23 int max = (int) Math. Sqrt (theMax) + 1;

24 if (max & 1) = 0) max --;

25 int [] primes = GetPrimes (GetSieve (min, max), min, max );

26 foreach (Range range in ranges)

27 {

28 min = range. Min;

29 max = range. Max;

30 if (min = 1) min = 3;

31 if (min & 1) = 0) min ++;

32 if (max & 1) = 0) max --;

33 OutPrimes (writer, GetSieve (primes, min, max), min, max, range. Min, range. Max );

34}

35}

36

37 Range [] GetRanges (TextReader reader, out int max)

38 {

39 max = 0;

40 Range [] ranges = new Range [int. Parse (reader. ReadLine ()];

41 for (int I = 0; I <ranges. Length; I ++)

42 {

43 string [] ss = reader. ReadLine (). Split ();

44 ranges [I]. Min = int. Parse (ss [0]);

45 ranges [I]. Max = int. Parse (ss [1]);

46 if (max <ranges [I]. Max) max = ranges [I]. Max;

47}

48 return ranges;

49}

50

51 bool [] GetSieve (int min, int max)

52 {

53 bool [] sieve = new bool [(max-min)> 1) + 1];

54 int sqrt = (int) Math. Sqrt (max) + 1;

55 for (int n = min; n <= sqrt; n + = 2) if (! Sieve [(n-min)> 1]) SetSieve (sieve, n, min, max );

56 return sieve;

57}

58

59 bool [] GetSieve (int [] primes, int min, int max)

60 {

61 bool [] sieve = new bool [(max-min)> 1) + 1];

62 int sqrt = (int) Math. Sqrt (max) + 1;

63 for (int I = 0; primes [I] <= sqrt; I ++) SetSieve (sieve, primes [I], min, max );

64 return sieve;

65}

66

67 void SetSieve (bool [] sieve, int v, int min, int max)

68 {

69 int step = v <1;

70 for (int n = GetStart (v, min); n <= max; n + = step) sieve [(n-min)> 1] = true;

71}

72

73 int GetStart (int v, int min)

74 {

75 int v2 = v * v;

76 if (v2> = min) return v2;

77 int x = min/v;

78 if (x & 1) = 0) x ++;

79 v2 = x * v;

80 if (v2 <min) v2 + = v * 2;

81 return v2;

82}

83

84 int [] GetPrimes (bool [] sieve, int min, int max)

85 {

86 int [] primes = new int [3401];

87 int I = 0;

88 for (int n = min; n <= max; n + = 2) if (! Sieve [(n-min)> 1]) primes [I ++] = n;

89 primes [I] = int. MaxValue;

90 return primes;

91}

92

93 void OutPrimes (TextWriter writer, bool [] sieve, int min, int max, int min0, int max0)

94 {

95 if (min0 <= 2 & max0> = 2) writer. WriteLine (2 );

96 for (int n = min; n <= max; n + = 2) if (! Sieve [(n-min)> 1]) writer. WriteLine (n );

97 writer. WriteLine ();

98}

99}

100

Sphere Onlile Judge (SPOJ) should use the Linux operating system. Currently, the C # compiler is mcs 1.0.1 (a little old, the latest version is 1.9.1), and the C/C ++ compiler is gcc 4.0.0-8 (a little old, the latest version is 4.3.1 ).