ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1048. Сверхдлинные суммы

Please give me some advice!
Послано Endorphin 23 апр 2011 00:20
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!
Послано AterLux 23 апр 2011 01:11
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!
Послано Endorphin 24 апр 2011 00:11
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!
Послано Gio Pataraia [Tbilisi SU] 27 апр 2011 04:24
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!
Послано Gio Pataraia [Tbilisi SU] 27 апр 2011 04:25
p.s use Console.nextInt(); or nextShort() it also works :)
Re: Please give me some advice!
Послано ssau_617_korabelnik 30 окт 2011 04:35
do u try input in example?