|
|
вернуться в форумPlease give me some advice! I've got WA on second test with code on C#: using System; using System.Numerics; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string s = Console.ReadLine(); int n = int.Parse(s);
string a1 = ""; string b1 = "";
for (int i = 0; i < n; i++) { string tmp = Console.ReadLine(); a1 += tmp[0].ToString(); b1 += tmp[2].ToString(); } BigInteger a = BigInteger.Parse(a1); BigInteger b = BigInteger.Parse(b1); Console.WriteLine(a + b); Console.Read(); } } } Could you tell me, where is my mistake? Re: Please give me some advice! I do not know C#, but, for example, in Java a + b not allowed to BigIntegers, may be you need to need a.add(b) instead? Anyway, forget all your BigIntegers, Maps, Sets, ArrayLists and other chetering things: it's not sportsmanship ;) Re: Please give me some advice! I tried to use a.add(b) instead. Nothing happened. :( As for "chetering things", may be you are right... Re: Please give me some advice! why do you read integers as strings? just read them us some array like this: array a b; 4 0 4 4 2 6 8 3 7 when you see 4 resize arrays 4; than int i=4; while(i>0) read a[i],b[i] than you have to sum them 0 4 6 3 +4 2 8 7 -------- 4 7 5 0 Re: Please give me some advice! p.s use Console.nextInt(); or nextShort() it also works :) Re: Please give me some advice! do u try input in example? |
|
|